Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
8.6 KiB

  1. // Copyright (c) 1995-1998 Microsoft Corporation
  2. /*
  3. * Tray notification message
  4. * */
  5. #define MYWM_BASE (WM_APP+100)
  6. //#define MYWM_NOTIFYICON (MYWM_BASE+0)
  7. #define MYWM_TIMER (MYWM_BASE+1)
  8. #define MYWM_RESTART (MYWM_BASE+2)
  9. //#define MYWM_FREECHILD (MYWM_BASE+3)
  10. //#define MYWM_ADDCHILD (MYWM_BASE+4)
  11. #define MYWM_HELPTOPICS (MYWM_BASE+5)
  12. #define MYWM_WAKEUP (MYWM_BASE+6)
  13. /*
  14. * MMSYS.CPL notifcation to kill tray volume
  15. * */
  16. //#define MYWM_KILLTRAYVOLUME (WM_USER+100)
  17. //#define REGSTR_PATH_MEDIA "SYSTEM\\CurrentControlSet\\Control\\MediaResources"
  18. //#define REGSTR_PATH_MEDIATMP REGSTR_PATH_MEDIA "\\tmp"
  19. //#define REGKEY_TRAYVOL "TrayVolumeControlWindow"
  20. /*
  21. * Upon an option change, the dialog box can force a reinit
  22. * */
  23. #define MIXUI_EXIT 0
  24. #define MIXUI_RESTART 1
  25. #define MIXUI_ERROR 2
  26. #define MIXUI_MMSYSERR 3
  27. #define GET (TRUE)
  28. #define SET (!GET)
  29. #define VOLUME_TICS (500L) // VOLUME_TICS * VOLUME_MAX must be less than 0xFFFFFFFF
  30. #define VOLUME_MIN (0L)
  31. #define VOLUME_MAX (65535L)
  32. #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
  33. #define SLIDER_TO_VOLUME(pos) (VOLUME_MIN + ((VOLUME_RANGE * pos + VOLUME_TICS / 2) / VOLUME_TICS))
  34. #define VOLUME_TO_SLIDER(vol) ((VOLUME_TICS * (vol - VOLUME_MIN) + VOLUME_RANGE / 2) / VOLUME_RANGE)
  35. #define MXUC_STYLEF_VISIBLE 0x00000001
  36. #define MXUC_STYLEF_ENABLED 0x00000002
  37. typedef struct t_MIXUICTRL
  38. {
  39. DWORD dwStyle; // ui style (see style flags)
  40. HWND hwnd; // hwnd to control
  41. int state; // app init state
  42. } MIXUICTRL, * PMIXUICTRL, FAR * LPMIXUICTRL;
  43. typedef enum
  44. {
  45. MIXUI_VOLUME = 0,
  46. MIXUI_BALANCE,
  47. MIXUI_SWITCH,
  48. MIXUI_VUMETER,
  49. MIXUI_ADVANCED,
  50. MIXUI_MULTICHANNEL
  51. } MIXUICONTROL;
  52. typedef enum
  53. {
  54. MIXUI_CONTROL_UNINITIALIZED = 0,
  55. MIXUI_CONTROL_ENABLED,
  56. MIXUI_CONTROL_INITIALIZED
  57. };
  58. #define MIXUI_FIRST MIXUI_VOLUME
  59. #define MIXUI_LAST MIXUI_VUMETER
  60. typedef struct t_MIXUILINE
  61. {
  62. MIXUICTRL acr [4]; // 5 fixed types
  63. DWORD dwStyle; // line style
  64. struct t_VOLCTRLDESC * pvcd; // ptr to volume description
  65. } MIXUILINE, * PMIXUILINE, FAR * LPMIXUILINE;
  66. /*
  67. * LOWORD == type
  68. * HIWORD == style
  69. */
  70. #define MXUL_STYLEF_DESTINATION 0x00000001
  71. #define MXUL_STYLEF_SOURCE 0x00000002
  72. #define MXUL_STYLEF_HIDDEN 0x00010000
  73. #define MXUL_STYLEF_DISABLED 0x00020000
  74. /*
  75. * The MIXUIDIALOG data structure is a global variable baggage to be
  76. * attached to dialogs and other windows. This allows to let windows
  77. * carry state information rather than us keeping track of it. It also
  78. * allows us to simply clone off of another dialog state with simple
  79. * changes.
  80. */
  81. typedef struct t_MIXUIDIALOG
  82. {
  83. HINSTANCE hInstance; // app instance
  84. HWND hwnd; // this window
  85. DWORD dwFlags; // random flags
  86. HMIXER hmx; // open handle to mixer
  87. DWORD mxid; // mixer id
  88. DWORD dwDevNode; // mixer dev node
  89. DWORD iDest; // destination line id
  90. DWORD dwStyle; // visual options.
  91. TCHAR szMixer[MAXPNAMELEN]; // product name
  92. TCHAR szDestination[MIXER_SHORT_NAME_CHARS]; // line name
  93. LPBYTE lpDialog; // ptr to dialog template
  94. DWORD cbDialog; // sizeof dialog buffer
  95. PMIXUILINE amxul; // ptr to array of mixuiline's
  96. DWORD cmxul; // number of lines
  97. struct t_VOLCTRLDESC *avcd; // array of volume descriptions
  98. DWORD cvcd; // number of volume descriptions
  99. HWND hParent; // HWND of parent window
  100. UINT uTimerID; // peakmeter timer
  101. HWND hStatus; // HWND of status bar
  102. WNDPROC lpfnTrayVol;// Tray volume subclass trackbar
  103. DWORD dwTrayInfo; // Tray volume info
  104. int nShowCmd; // init window
  105. DWORD dwDeviceState; // device change state information
  106. int cTimeInQueue; // timer messages in queue
  107. //
  108. // Return values from dialogs, etc.. can be put in dwReturn
  109. // Upon EndDialog, dwReturn gets set to MIXUI_EXIT or MIXUI_RESTART
  110. //
  111. DWORD dwReturn; // return value on exit
  112. MMRESULT mmr; // last result (iff dwReturn == MIXUI_MMSYSERR)
  113. RECT rcRestart; // restart position (iff dwReturn == MIXUI_RESTART)
  114. int cxDlgContent; // size of dialog content
  115. int cxDlgWidth; // width of dialog
  116. int xOffset; // offset if scrolling is needed
  117. int cxScroll; // amount to scroll by
  118. } MIXUIDIALOG, *PMIXUIDIALOG, FAR *LPMIXUIDIALOG;
  119. /*
  120. * Style bits - these generally determine the look of the app
  121. */
  122. #define MXUD_STYLEF_TRAYMASTER 0x00000002 // use the tray
  123. #define MXUD_STYLEF_MASTERONLY 0x00000004 // only destination volumes --obsolete
  124. #define MXUD_STYLEF_HORIZONTAL 0x00000008 // horizontal mode
  125. #define MXUD_STYLEF_TWOCHANNEL 0x00000010 // two channel slider volume
  126. #define MXUD_STYLEF_SMALL 0x00000020 // half-pint version
  127. #define MXUD_STYLEF_CHILD 0x00000040 // child window? --obsolete
  128. #define MXUD_STYLEF_KEEPWINDOW 0x00000080 // keep window --obsolete
  129. #define MXUD_STYLEF_NOHELP 0x00000100 // no help
  130. #define MXUD_STYLEF_STATUS 0x00000200 // status bar
  131. #define MXUD_STYLEF_TOPMOST 0x00000400 // top most window
  132. #define MXUD_STYLEF_ADVANCED 0x00000800 // show advanced
  133. #define MXUD_STYLEF_CLOSE 0x00001000 // find and close TRAYMASTER window
  134. /*
  135. * Flag bits - these generally indicate operating modes and internal info
  136. */
  137. #define MXUD_FLAGSF_MIXER 0x00000001 // bound to a mixer driver
  138. #define MXUD_FLAGSF_USETIMER 0x00000002 // update timer enabled
  139. #define MXUD_FLAGSF_BADDRIVER 0x00000004 // mixer driver with control map bug
  140. #define MXUD_FLAGSF_NOADVANCED 0x00000008 // advanced features disabled
  141. /*
  142. * Macro - if both advanced style and advanced state
  143. */
  144. #define MXUD_ADVANCED(x) (!((x)->dwFlags & MXUD_FLAGSF_NOADVANCED) && (x)->dwStyle & MXUD_STYLEF_ADVANCED)
  145. /*
  146. * Tray info bits - state bits for the tray volume
  147. */
  148. #define MXUD_TRAYINFOF_SIGNAL 0x00000001 // has a change been made?
  149. #define GETMIXUIDIALOG(x) (MIXUIDIALOG *)GetWindowLongPtr(x, DWLP_USER)
  150. #define SETMIXUIDIALOG(x,y) SetWindowLongPtr(x, DWLP_USER, y)
  151. DWORD ReadRegistryData( LPTSTR pEntryNode,
  152. LPTSTR pEntryName,
  153. PDWORD pType,
  154. LPBYTE pData,
  155. DWORD DataSize );
  156. DWORD WriteRegistryData( LPTSTR pEntryNode,
  157. LPTSTR pEntryName,
  158. DWORD Type,
  159. LPBYTE pData,
  160. DWORD Size );
  161. DWORD QueryRegistryDataSize( LPTSTR pEntryNode,
  162. LPTSTR pEntryName,
  163. DWORD *pDataSize );
  164. int Volume_NumDevs(void);
  165. HWND Volume_GetLineItem(HWND, DWORD, DWORD);
  166. BOOL Properties(PMIXUIDIALOG pmxud, HWND hwnd);
  167. #define HANDLE_WM_XSCROLL(hwnd, wParam, lParam, fn) \
  168. ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
  169. #define HANDLE_MM_MIXM_CONTROL_CHANGE(hwnd, wParam, lParam, fn) \
  170. ((fn)((hwnd), (HMIXER)(wParam), (DWORD)(lParam)))
  171. #define HANDLE_MM_MIXM_LINE_CHANGE(hwnd, wParam, lParam, fn) \
  172. ((fn)((hwnd), (HMIXER)(wParam), (DWORD)(lParam)))
  173. #define HANDLE_MYWM_TIMER(hwnd, wParam, lParam, fn) \
  174. ((fn)((hwnd)))
  175. #define HANDLE_WM_IDEVICECHANGE(hwnd, wParam, lParam, fn) \
  176. ((fn)((hwnd), wParam, lParam))
  177. #define HANDLE_MYWM_WAKEUP(hwnd, wParam, lParam, fn) \
  178. ((fn)((hwnd), wParam))
  179. #ifdef DEBUG
  180. static int _assert(LPSTR szExp, LPSTR szFile, UINT uLine)
  181. {
  182. const char szAssertText [] = "Assertion failed: %s, file %s, line %u\r\n";
  183. const char szAppName [] = "SNDVOL32";
  184. char sz[256];
  185. DWORD fDialog = 0L;
  186. wsprintf(sz, szAssertText, szExp, szFile, uLine);
  187. ReadRegistryData(NULL, "AssertDialog", NULL, (LPBYTE)&fDialog, sizeof(DWORD));
  188. if (fDialog)
  189. MessageBox(NULL, szAppName, sz, MB_OK|MB_ICONHAND);
  190. else
  191. {
  192. OutputDebugString(sz);
  193. DebugBreak();
  194. }
  195. return 1;
  196. }
  197. #define assert(exp) (void)( (exp) || (_assert(#exp, __FILE__, __LINE__), 0) )
  198. #define dout(exp) OutputDebugString(exp)
  199. static void _dlout(LPSTR szExp, LPSTR szFile, UINT uLine)
  200. {
  201. char sz[256];
  202. wsprintf(sz, "%s, file %s, line %u\r\n", szExp, szFile, uLine);
  203. OutputDebugString(sz);
  204. }
  205. #define dlout(exp) (void)(_dlout(exp, __FILE__, __LINE__), 0)
  206. #else
  207. #define assert(exp) ((void)0)
  208. #define dout(exp) ((void)0)
  209. #define dlout(exp) ((void)0)
  210. #endif
  211. #define VOLUME_TRAYSHUTDOWN_ID 1
  212. #define SIZEOF(x) (sizeof((x))/sizeof((x)[0]))
  213. #include "pvcd.h"
  214. #ifndef DRV_QUERYDEVNODE
  215. #define DRV_QUERYDEVNODE (DRV_RESERVED + 2)
  216. #endif