SHELL.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:11k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
  4.  *
  5.  *  File:       shell.h
  6.  *  Content:    DirectSound shell header
  7.  *
  8.  ***************************************************************************/
  9. #ifndef __SHELL_INCLUDED__
  10. #define __SHELL_INCLUDED__
  11. // If this is defined, then an extra text string under the filename will show
  12. // if the file is stopped or playing.
  13. #define SHOWSTATUS
  14. #define MAXCONTROLS             8
  15. // For setting the ranges on the freq, vol, etc.
  16. // dwFreq*FREQMUL+FREQADD = # to show on screen.
  17. #define FREQFACTOR              (5)                   
  18. #define FREQADD                 (0)
  19. #define FREQPAGE                (100)
  20. #define PANPAGE                 (5)
  21. #define MINFREQ_TB              0
  22. #define MAXFREQ_TB              100000
  23. #define MINPAN_TB               0
  24. #define MIDPAN_TB               400
  25. #define MAXPAN_TB               800
  26. #define SHIFTPAN_TB             (-400)
  27. #define MULTPAN_TB              (10L)
  28. #define MINPAN_VAL              (-400)
  29. #define MIDPAN_VAL              0
  30. #define MAXPAN_VAL              400
  31. #define MINVOL_TB               0
  32. #define MAXVOL_TB               400
  33. #define SHIFTVOL_TB             (-400)
  34. #define MULTVOL_TB              (10L)
  35. #define MINVOL_VAL              -400
  36. #define MAXVOL_VAL              0
  37. // Id code deltas
  38. #define idFreqTB                1
  39. #define idPanTB                 2
  40. #define idVolLTB                3
  41. #define idVolRTB                4
  42. #define idVolMTB                5
  43. #define idLoopedBN              6
  44. #define idPlayBN                7
  45. #define idRemoveBN              8
  46. // UI stuff.
  47. #define DX_WIN_BORDER           30
  48. #define DY_WIN_BORDER           30
  49. #define DX_MINWINDOW            640
  50. #define DY_MINWINDOW            450 // Was 560 Must tweek to keep above the taskbar <= 450
  51. #define DX_CONTROLSPACING       150
  52. #define DY_CONTROLSPACING       0
  53. #define DX_LINEEDGE             (DX_CONTROLSPACING - 20)
  54. #define DY_LINEEDGE             (1)
  55. #define COX_STARTCONTROL        (20) // Defines the left edge of the first file window
  56. #define COY_STARTCONTROL        (10) // Defines the upper edge of the first file window
  57. #define DX_TEXTSPACING          5
  58. #define DY_TEXTSPACING          10
  59. #define DX_LOOPEDSPACING        0    //Relative horizontal offset of top four areas
  60. #define DY_LOOPEDSPACING        -6 //Space offset around lines 
  61. #define DX_STATUSSPACING        0
  62. #ifdef SHOWSTATUS
  63. #define DY_STATUSSPACING        8
  64. #else
  65. #define DY_STATUSSPACING        0
  66. #endif
  67. #define DX_FREQSPACING          0
  68. #define DY_FREQSPACING          10
  69. #define DY_PANSPACING           10
  70. #define DY_VOLSPACING           10
  71. //Establish the Widths of various windows:
  72. #define DX_FILENAME_TXT         120 //Filename window
  73. #define DX_STATUS_TXT           120 //Status window
  74. #define DX_FREQ_TXT             120 //Frequency window
  75. #define DX_PAN_TXT              100 //Pan window
  76. #define DX_VOL_TXT              100 //Volume window
  77. #define DX_LOOPED_TXT           100 //Checkbox + 'Looped' window
  78. //Establish slider sizes:
  79. #define DX_FREQ_TB              130 //Frequency slider width
  80. #define DY_FREQ_TB              40 //Frequency slider height
  81. #define DX_PAN_TB 130 //Pan slider width
  82. #define DY_PAN_TB               40 //Pan slider height
  83. #define DX_VOL_TB               40 //Master volume slider width
  84. #define DY_VOL_TB               100 //Master volume slider height
  85. #define DX_VOLSPACING_TB        5 //Distance between master volume and its label
  86. #define DX_VOLUMECHAR           15
  87. #define DY_VOLSPACINGY          -5 //Distance between channel mixers and L & R labels 
  88. #define DX_BUTTONSPACING        61 //Width of the Play and Remove buttons
  89. #define DY_BUTTONSPACING        10
  90. #define DY_BEFOREFIRSTBUTTON    18 //Distance above and below Volume->buttons line
  91. #define DY_BETWEENBUTTONS       5 //Vertical space between buttons
  92. #define DX_FRAMEEDGE            10 //Distance between leftmost control and the window edge
  93. #define DY_FRAMEEDGE            10 //Distance between outermost contol and the window edge
  94. #define DX_FRAMEEDGEINNER       4 //Distance between file windows
  95. // To check for stopping of sounds, a timer is set...use this for the rate.
  96. #define TIMERPERIOD 500 // In milliseconds
  97. // In Options/Output Type, there are strings to pick the format...Here are the number of them.
  98. #define C_DROPDOWNPCMFORMATS    16
  99. typedef struct _fileinfo
  100.     {
  101.     BYTE                *pbData;        // Pointer to actual data of file.
  102.     UINT                cbSize;         // Size of data.
  103.     WAVEFORMATEX *pwfx;          // Pointer to waveformatex structure.
  104.     DWORD               dwFreq;         // Frequency.
  105.     DWORD               dwPan;          // Panning info.
  106.     DWORD               dwVol;          // Total volume.
  107.     BOOL                fLooped;        // Looped?
  108.     BOOL                fPlaying;       // Is this one playing?
  109.     BOOL                fLost;          // Is this one lost?
  110.     BOOL                fHardware;      // Is this a hardware buffer?
  111.     BOOL                fSticky;        // Is this a sticky buffer?
  112.     int cox;            // Coordinates of where the structure is
  113.     int coy;            // printed.
  114.     // HWND's needed.
  115.     HWND                hWndFileName_TXT;   // Filename text string.
  116.     HWND                hWndFreq_TB;        // Trackbar handle.
  117.     HWND                hWndFreq_TXT;       // Text string for freq.
  118.     HWND                hWndPan_TB;         // Trackbar handle.
  119.     HWND                hWndPan_TXT;        // Text string for pan.
  120.     HWND                hWndVol_TXT;        // Text string for volume.
  121.     HWND                hWndVolL_TB;        // Trackbar for volume left.
  122.     HWND                hWndVolR_TB;        // Trackbar for volume right.
  123.     HWND                hWndVolM_TB;        // Main volume.
  124.     HWND                hWndLooped_BN;      // Looped
  125.     HWND                hWndPlay_BN;        // Play
  126.     HWND                hWndRemove_BN;      // Remove.
  127.     
  128.     HWND                hWndFileName_EDGE;  // The line under filename.
  129.     HWND                hWndLooped_EDGE;    // The line under looped.
  130.     HWND                hWndFreq_EDGE;      // The line under freq.
  131.     HWND                hWndPan_EDGE;       // The line under pan.
  132.     HWND                hWndVol_EDGE;       // The line under volume.
  133.     HWND                hWndWhole_EDGE;     // The whole surrounding edge.
  134.     HWND                hWndVolL_TXT;       // For the L
  135.     HWND                hWndVolR_TXT;       // For the R
  136.     #ifdef SHOWSTATUS
  137.     HWND                hWndStatus_TXT;     // For status.
  138.     HWND                hWndStatus_EDGE;
  139.     HWND                hWndPlayPosition_TXT;
  140.     HWND                hWndPlayPosition_EDGE;
  141.     HWND                hWndWritePosition_TXT;
  142.     HWND                hWndWritePosition_EDGE;
  143.     #endif
  144.     LPDIRECTSOUNDBUFFER pDSB;               // Pointer to direct sound buffer.
  145.     int                 nFileName;          // Index to filename, not including dir.
  146.     char                szFileName[MAX_PATH];
  147.     struct _fileinfo    *pNext;             // Pointer to next file.
  148.     } FILEINFO;
  149. char            szAppName[]     = "Direct Sound Demo";
  150. char            szMessage[]     = "Direct Sound Demo";
  151. char gszCDStartPath[MAX_PATH];         // The path to start the Open dialog in
  152. // Registry Key and Value names that allow us to retrive a path something like
  153. // "C:DXSDKSDKMEDIA", but matching the current install.
  154. const TCHAR gszRegKeyDirect3D[] = TEXT("Software\Microsoft\Direct3D");
  155. const TCHAR gszRegValueD3DPath[] = TEXT("D3D Path");
  156. HANDLE          hInst;
  157. HWND            hWndMain        = NULL;
  158. DWORD           dwTimer         = 0;     // Timer handle.
  159. GUID                    guID;
  160. BOOL                    fEnumDrivers = FALSE;
  161. /*  This is the main head of the linked list, but its only used for the
  162.     pNext which will point to the first FILEINFO structure, or NULL if there
  163.     are no files loaded  */
  164. FILEINFO        FileInfoFirst;              // Start of linked list.
  165. char            szFreq[]        = "Freq";
  166. char            szPan[]         = "Pan";
  167. char            szVolume[]      = "Volume";
  168. char            szLooped[]      = "Looped";
  169. char            szPlay[]        = "Play";
  170. char            szStop[]        = "Stop";
  171. char            szRemove[]      = "Close";
  172. #ifdef SHOWSTATUS
  173. char            szFmtPlayPosition[] = "Play %d";
  174. char            szFmtWritePosition[]    = "Write %d";
  175. char            szPlaying[]     = "Playing";
  176. char            szStopped[]     = "Stopped";
  177. char            szSticky[]      = "Sticky";
  178. char                    szLost[]        = "Lost";
  179. char            szHW[]          = "HW-";
  180. char                    szSW[]                  = "SW-";
  181. #endif
  182. char *rgszTypes[C_DROPDOWNPCMFORMATS] = 
  183.     {                                       // Index
  184.     "8.000 kHz, 8-Bit, Mono",               // 0
  185.     "8.000 kHz, 8-Bit, Stereo",             // 1
  186.     "8.000 kHz, 16-Bit, Mono",              // 2
  187.     "8.000 kHz, 16-Bit, Stereo",            // 3
  188.     "11.025 kHz, 8-Bit, Mono",              // 4
  189.     "11.025 kHz, 8-Bit, Stereo",            // 5
  190.     "11.025 kHz, 16-Bit, Mono",             // 6
  191.     "11.025 kHz, 16-Bit, Stereo",           // 7
  192.     "22.050 kHz, 8-Bit, Mono",              // 8
  193.     "22.050 kHz, 8-Bit, Stereo",            // 9
  194.     "22.050 kHz, 16-Bit, Mono",             // 10
  195.     "22,050 kHz, 16-Bit, Stereo",           // 11
  196.     "44.100 kHz, 8-Bit, Mono",              // 12
  197.     "44.100 kHz, 8-Bit, Stereo",            // 13
  198.     "44.100 kHz, 16-Bit, Mono",             // 14
  199.     "44.100 kHz, 16-Bit, Stereo"            // 15
  200.     };                                      
  201. BOOL                    rgfcoxAvail[MAXCONTROLS];
  202. LPDIRECTSOUND           gpds            = NULL;
  203. long FAR PASCAL WndProc(HWND, unsigned, WPARAM, LPARAM);
  204. long FAR PASCAL DLGHelpAbout(HWND, UINT, WPARAM, LPARAM);
  205. long FAR PASCAL DLGOutputBufferType(HWND, UINT, WPARAM, LPARAM);
  206. long FAR PASCAL DLGCheckLatency(HWND, UINT, WPARAM, LPARAM);
  207. UINT CALLBACK FileOpenCustomTemplateDlgProc(HWND, UINT, WPARAM, LPARAM);
  208. BOOL ClassInit(HANDLE);
  209. void PD_FileOpen(HWND);
  210. BOOL OpenFileDialog(HWND, LPSTR, int *, LPBOOL);
  211. BOOL IsValidWave(LPSTR);
  212. void GetMediaStartPath(void);
  213. int CreateControl(HWND, FILEINFO *, DWORD, DWORD, DWORD);
  214. void GetNextControlCoords(FILEINFO *, int *, int *);
  215. int AddToList(FILEINFO *, FILEINFO *);
  216. int FreeAllList(HWND, FILEINFO *);
  217. int RemoveFromList(FILEINFO *, FILEINFO *);
  218. int GetNumControls(FILEINFO *);
  219. int StartDSound(HWND, FILEINFO *);
  220. int StopDSound(HWND, FILEINFO *);
  221. int StopAllDSounds(HWND, FILEINFO *);
  222. BOOL UIMainWindowVSBHandler(HWND, WPARAM, LPARAM); 
  223. BOOL UIMainWindowHSBHandler(HWND, WPARAM, LPARAM); 
  224. BOOL UIMainWindowCMDHandler(HWND, WPARAM, LPARAM); 
  225. BOOL UIMainWindowTimerHandler(HWND, WPARAM, LPARAM); 
  226. void SetAllText(FILEINFO *);
  227. void UpdateLRVolume(FILEINFO *);
  228. void AppDestroy(HWND);
  229. BOOL AppInit(HWND);
  230. BOOL ParseCommandLine(PSTR);
  231. BOOL BatchOpenFiles(PSTR *,int,BOOL,BOOL);
  232. int NewDirectSoundBuffer(FILEINFO *);
  233. int ReleaseDirectSoundBuffer(FILEINFO *);
  234. int ChangeOutputPan(FILEINFO *);
  235. int ChangeOutputFreq(FILEINFO *);
  236. int ChangeOutputVol(FILEINFO *);
  237. int FormatToIndex(HWND, FILEINFO *);
  238. int IndexToFormat(HWND, FILEINFO *, int);
  239. #endif