ReactOS 0.4.15-dev-5672-gf73ac17
volume.c File Reference
#include "mmsys.h"
#include <shellapi.h>
Include dependency graph for volume.c:

Go to the source code of this file.

Classes

struct  _GLOBAL_DATA
 

Typedefs

typedef struct _GLOBAL_DATA GLOBAL_DATA
 
typedef struct _GLOBAL_DATAPGLOBAL_DATA
 

Functions

VOID GetMuteControl (PGLOBAL_DATA pGlobalData)
 
VOID GetMuteState (PGLOBAL_DATA pGlobalData)
 
VOID SwitchMuteState (PGLOBAL_DATA pGlobalData)
 
VOID GetVolumeControl (PGLOBAL_DATA pGlobalData)
 
VOID GetVolumeValue (PGLOBAL_DATA pGlobalData, BOOL bInit)
 
VOID SetVolumeValue (PGLOBAL_DATA pGlobalData, DWORD dwPosition)
 
static VOID RestoreVolumeValue (PGLOBAL_DATA pGlobalData)
 
static VOID SetSystrayVolumeIconState (BOOL bEnabled)
 
static BOOL GetSystrayVolumeIconState (VOID)
 
VOID InitVolumeControls (HWND hwndDlg, PGLOBAL_DATA pGlobalData)
 
VOID SaveData (HWND hwndDlg)
 
VOID LaunchSoundControl (HWND hwndDlg)
 
INT_PTR CALLBACK VolumeDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ GLOBAL_DATA

◆ PGLOBAL_DATA

Function Documentation

◆ GetMuteControl()

VOID GetMuteControl ( PGLOBAL_DATA  pGlobalData)

Definition at line 41 of file volume.c.

42{
43 MIXERLINEW mxln;
44 MIXERCONTROLW mxc;
45 MIXERLINECONTROLSW mxlctrl;
46
47 if (pGlobalData->hMixer == NULL)
48 return;
49
50 mxln.cbStruct = sizeof(MIXERLINEW);
52
55 return;
56
57 mxlctrl.cbStruct = sizeof(MIXERLINECONTROLSW);
58 mxlctrl.dwLineID = mxln.dwLineID;
60 mxlctrl.cControls = 1;
61 mxlctrl.cbmxctrl = sizeof(MIXERCONTROLW);
62 mxlctrl.pamxctrl = &mxc;
63
66 return;
67
68 pGlobalData->muteControlID = mxc.dwControlID;
69}
#define NULL
Definition: types.h:112
struct tagMIXERLINECONTROLSW MIXERLINECONTROLSW
#define MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
Definition: mmsystem.h:319
struct tagMIXERCONTROLW MIXERCONTROLW
#define MIXER_GETLINEINFOF_COMPONENTTYPE
Definition: mmsystem.h:347
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MIXER_GETLINECONTROLSF_ONEBYTYPE
Definition: mmsystem.h:410
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
struct tagMIXERLINEW MIXERLINEW
#define MIXERCONTROL_CONTROLTYPE_MUTE
Definition: mmsystem.h:384
HMIXER hMixer
Definition: volume.c:17
DWORD muteControlID
Definition: volume.c:24
LPMIXERCONTROLW pamxctrl
Definition: mmsystem.h:1350
DWORD dwLineID
Definition: mmsystem.h:1258
DWORD cbStruct
Definition: mmsystem.h:1255
DWORD dwComponentType
Definition: mmsystem.h:1261
UINT WINAPI mixerGetLineControlsW(HMIXEROBJ hmix, LPMIXERLINECONTROLSW lpmlcW, DWORD fdwControls)
Definition: winmm.c:574
UINT WINAPI mixerGetLineInfoW(HMIXEROBJ hmix, LPMIXERLINEW lpmliW, DWORD fdwInfo)
Definition: winmm.c:595

Referenced by InitVolumeControls().

◆ GetMuteState()

VOID GetMuteState ( PGLOBAL_DATA  pGlobalData)

Definition at line 73 of file volume.c.

74{
77
78 if (pGlobalData->hMixer == NULL)
79 return;
80
81 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
82 mxcd.dwControlID = pGlobalData->muteControlID;
83 mxcd.cChannels = 1;
84 mxcd.cMultipleItems = 0;
86 mxcd.paDetails = &mxcdMute;
87
90 return;
91
92 pGlobalData->muteVal = mxcdMute.fValue;
93}
#define MIXER_GETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:412
struct tMIXERCONTROLDETAILS_BOOLEAN MIXERCONTROLDETAILS_BOOLEAN
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS
LONG muteVal
Definition: volume.c:23
UINT WINAPI mixerGetControlDetailsW(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcdW, DWORD fdwDetails)
Definition: winmm.c:426

Referenced by InitVolumeControls(), and VolumeDlgProc().

◆ GetSystrayVolumeIconState()

static BOOL GetSystrayVolumeIconState ( VOID  )
static

Definition at line 288 of file volume.c.

289{
290 HWND hwndTaskBar;
291
292 hwndTaskBar = FindWindowW(L"SystemTray_Main", NULL);
293 if (hwndTaskBar == NULL)
294 {
295 return FALSE;
296 }
297
298 return (BOOL)SendMessageW(hwndTaskBar, WM_USER + 221, 4, 0);
299}
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define L(x)
Definition: ntvdm.h:50
#define WM_USER
Definition: winuser.h:1885
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by InitVolumeControls().

◆ GetVolumeControl()

VOID GetVolumeControl ( PGLOBAL_DATA  pGlobalData)

Definition at line 119 of file volume.c.

120{
121 MIXERLINEW mxln;
122 MIXERCONTROLW mxc;
124
125 if (pGlobalData->hMixer == NULL)
126 return;
127
128 mxln.cbStruct = sizeof(MIXERLINEW);
132 return;
133
134 pGlobalData->volumeChannels = mxln.cChannels;
135
136 mxlc.cbStruct = sizeof(MIXERLINECONTROLSW);
137 mxlc.dwLineID = mxln.dwLineID;
139 mxlc.cControls = 1;
140 mxlc.cbmxctrl = sizeof(MIXERCONTROLW);
141 mxlc.pamxctrl = &mxc;
144 return;
145
146 pGlobalData->volumeMinimum = mxc.Bounds.dwMinimum;
147 pGlobalData->volumeMaximum = mxc.Bounds.dwMaximum;
148 pGlobalData->volumeControlID = mxc.dwControlID;
149 pGlobalData->volumeStep = (pGlobalData->volumeMaximum - pGlobalData->volumeMinimum) / (VOLUME_MAX - VOLUME_MIN);
150
152 0,
154 if (pGlobalData->volumeInitialValues == NULL)
155 return;
156
158 0,
160 if (pGlobalData->volumePreviousValues == NULL)
161 return;
162
164 0,
166 if (pGlobalData->volumeCurrentValues == NULL)
167 return;
168}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MIXERCONTROL_CONTROLTYPE_VOLUME
Definition: mmsystem.h:398
#define VOLUME_MAX
Definition: sndvol32.h:19
#define VOLUME_MIN
Definition: sndvol32.h:18
DWORD volumeChannels
Definition: volume.c:27
PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues
Definition: volume.c:35
DWORD volumeMaximum
Definition: volume.c:29
PMIXERCONTROLDETAILS_UNSIGNED volumePreviousValues
Definition: volume.c:34
PMIXERCONTROLDETAILS_UNSIGNED volumeInitialValues
Definition: volume.c:33
DWORD volumeMinimum
Definition: volume.c:28
DWORD volumeControlID
Definition: volume.c:26
DWORD volumeStep
Definition: volume.c:30
union tagMIXERCONTROLW::@3022 Bounds
DWORD cChannels
Definition: mmsystem.h:1262

Referenced by InitVolumeControls().

◆ GetVolumeValue()

VOID GetVolumeValue ( PGLOBAL_DATA  pGlobalData,
BOOL  bInit 
)

Definition at line 172 of file volume.c.

175{
177 DWORD i;
178
179 if (pGlobalData->hMixer == NULL)
180 return;
181
182 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
183 mxcd.dwControlID = pGlobalData->volumeControlID;
184 mxcd.cChannels = pGlobalData->volumeChannels;
185 mxcd.cMultipleItems = 0;
187 mxcd.paDetails = pGlobalData->volumePreviousValues;
188
191 return;
192
193 pGlobalData->maxVolume = 0;
194 for (i = 0; i < pGlobalData->volumeChannels; i++)
195 {
196 pGlobalData->volumeCurrentValues[i].dwValue = pGlobalData->volumePreviousValues[i].dwValue;
197
198 if (pGlobalData->volumePreviousValues[i].dwValue > pGlobalData->maxVolume)
199 pGlobalData->maxVolume = pGlobalData->volumePreviousValues[i].dwValue;
200
201 if (bInit)
202 pGlobalData->volumeInitialValues[i].dwValue = pGlobalData->volumeCurrentValues[i].dwValue;
203 }
204}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct tMIXERCONTROLDETAILS_UNSIGNED MIXERCONTROLDETAILS_UNSIGNED
DWORD maxVolume
Definition: volume.c:32

Referenced by InitVolumeControls(), and VolumeDlgProc().

◆ InitVolumeControls()

VOID InitVolumeControls ( HWND  hwndDlg,
PGLOBAL_DATA  pGlobalData 
)

Definition at line 302 of file volume.c.

303{
304 UINT NumMixers;
305 MIXERCAPSW mxc;
306 WCHAR szNoDevices[256];
307
308 LoadStringW(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
309
313
314 NumMixers = mixerGetNumDevs();
315 if (!NumMixers)
316 {
326 SetDlgItemTextW(hwndDlg, IDC_DEVICE_NAME, szNoDevices);
327 return;
328 }
329
330 if (mixerOpen(&pGlobalData->hMixer, 0, PtrToUlong(hwndDlg), 0, MIXER_OBJECTF_MIXER | CALLBACK_WINDOW) != MMSYSERR_NOERROR)
331 {
332 MessageBoxW(hwndDlg, L"Cannot open mixer", NULL, MB_OK);
333 return;
334 }
335
336 ZeroMemory(&mxc, sizeof(MIXERCAPSW));
337 if (mixerGetDevCapsW(PtrToUint(pGlobalData->hMixer), &mxc, sizeof(MIXERCAPSW)) != MMSYSERR_NOERROR)
338 {
339 MessageBoxW(hwndDlg, L"mixerGetDevCaps failed", NULL, MB_OK);
340 return;
341 }
342
343 CheckDlgButton(hwndDlg,
346
347 GetMuteControl(pGlobalData);
348 GetMuteState(pGlobalData);
349 if (pGlobalData->muteVal)
350 {
353 }
354 else
355 {
358 }
359
360 GetVolumeControl(pGlobalData);
361 GetVolumeValue(pGlobalData, TRUE);
362
364 SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
365}
#define PtrToUint(p)
Definition: basetsd.h:85
#define TRUE
Definition: types.h:120
HINSTANCE hApplet
Definition: access.c:17
#define IDC_ICON_IN_TASKBAR
Definition: resource.h:37
#define IDC_VOLUME_HIGH
Definition: resource.h:35
#define IDC_VOLUME_LOW
Definition: resource.h:34
#define IDC_MUTE_ICON
Definition: resource.h:71
#define IDC_VOLUME_TRACKBAR
Definition: resource.h:33
#define IDC_DEVICE_NAME
Definition: resource.h:50
#define IDC_ADVANCED_BTN
Definition: resource.h:51
#define IDC_ADVANCED2_BTN
Definition: resource.h:54
#define IDC_SPEAKER_VOL_BTN
Definition: resource.h:53
#define IDC_MUTE_CHECKBOX
Definition: resource.h:36
#define IDS_NO_DEVICES
Definition: resource.h:91
static BOOL GetSystrayVolumeIconState(VOID)
Definition: volume.c:288
VOID GetMuteControl(PGLOBAL_DATA pGlobalData)
Definition: volume.c:41
VOID GetVolumeValue(PGLOBAL_DATA pGlobalData, BOOL bInit)
Definition: volume.c:172
VOID GetMuteState(PGLOBAL_DATA pGlobalData)
Definition: volume.c:73
VOID GetVolumeControl(PGLOBAL_DATA pGlobalData)
Definition: volume.c:119
#define PtrToUlong(u)
Definition: config.h:107
#define VOLUME_PAGESIZE
Definition: mmsys.h:45
#define VOLUME_TICFREQ
Definition: mmsys.h:44
#define CALLBACK_WINDOW
Definition: mmsystem.h:148
#define MIXER_OBJECTF_MIXER
Definition: mmsystem.h:300
unsigned int UINT
Definition: ndis.h:50
#define TBM_SETPAGESIZE
Definition: commctrl.h:2051
#define TBM_SETRANGE
Definition: commctrl.h:2037
#define TBM_SETPOS
Definition: commctrl.h:2036
#define TBM_SETTICFREQ
Definition: commctrl.h:2050
#define _countof(array)
Definition: sndvol32.h:68
HICON hIconMuted
Definition: volume.c:18
HICON hIconNoHW
Definition: volume.c:20
HICON hIconUnMuted
Definition: volume.c:19
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1226
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define ZeroMemory
Definition: winbase.h:1670
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
UINT WINAPI mixerGetDevCapsW(UINT_PTR uDeviceID, LPMIXERCAPSW lpCaps, UINT uSize)
Definition: winmm.c:317
UINT WINAPI mixerGetNumDevs(void)
Definition: winmm.c:283
UINT WINAPI mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
Definition: winmm.c:342
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
#define IMAGE_ICON
Definition: winuser.h:212
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define STM_SETIMAGE
Definition: winuser.h:2083
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define BM_SETCHECK
Definition: winuser.h:1911
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1607
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define MB_OK
Definition: winuser.h:784
#define BST_CHECKED
Definition: winuser.h:197
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by VolumeDlgProc().

◆ LaunchSoundControl()

VOID LaunchSoundControl ( HWND  hwndDlg)

Definition at line 378 of file volume.c.

379{
380 if ((INT_PTR)ShellExecuteW(NULL, L"open", L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL) > 32)
381 return;
382 MessageBoxW(hwndDlg, L"Cannot run sndvol32.exe", NULL, MB_OK);
383}
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2346
int32_t INT_PTR
Definition: typedefs.h:64
#define SW_SHOWNORMAL
Definition: winuser.h:764

Referenced by VolumeDlgProc().

◆ RestoreVolumeValue()

static VOID RestoreVolumeValue ( PGLOBAL_DATA  pGlobalData)
static

Definition at line 252 of file volume.c.

254{
256
257 if (pGlobalData->hMixer == NULL)
258 return;
259
260 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
261 mxcd.dwControlID = pGlobalData->volumeControlID;
262 mxcd.cChannels = pGlobalData->volumeChannels;
263 mxcd.cMultipleItems = 0;
265 mxcd.paDetails = pGlobalData->volumeInitialValues;
266
267 mixerSetControlDetails((HMIXEROBJ)pGlobalData->hMixer,
268 &mxcd,
270}
#define MIXER_SETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:415
UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
Definition: winmm.c:684

Referenced by VolumeDlgProc().

◆ SaveData()

VOID SaveData ( HWND  hwndDlg)

Definition at line 368 of file volume.c.

369{
370 BOOL bShowIcon;
371
372 bShowIcon = (IsDlgButtonChecked(hwndDlg, IDC_ICON_IN_TASKBAR) == BST_CHECKED);
373
374 SetSystrayVolumeIconState(bShowIcon);
375}
static VOID SetSystrayVolumeIconState(BOOL bEnabled)
Definition: volume.c:275
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)

Referenced by DECLARE_INTERFACE_(), and VolumeDlgProc().

◆ SetSystrayVolumeIconState()

static VOID SetSystrayVolumeIconState ( BOOL  bEnabled)
static

Definition at line 275 of file volume.c.

276{
277 HWND hwndTaskBar;
278
279 hwndTaskBar = FindWindowW(L"SystemTray_Main", NULL);
280 if (hwndTaskBar == NULL)
281 return;
282
283 SendMessageW(hwndTaskBar, WM_USER + 220, 4, bEnabled);
284}

Referenced by SaveData().

◆ SetVolumeValue()

VOID SetVolumeValue ( PGLOBAL_DATA  pGlobalData,
DWORD  dwPosition 
)

Definition at line 208 of file volume.c.

210{
212 DWORD dwVolume, i;
213
214 if (pGlobalData->hMixer == NULL)
215 return;
216
217 if (dwPosition == VOLUME_MIN)
218 dwVolume = pGlobalData->volumeMinimum;
219 else if (dwPosition == VOLUME_MAX)
220 dwVolume = pGlobalData->volumeMaximum;
221 else
222 dwVolume = (dwPosition * pGlobalData->volumeStep) + pGlobalData->volumeMinimum;
223
224 for (i = 0; i < pGlobalData->volumeChannels; i++)
225 {
226 if (pGlobalData->volumePreviousValues[i].dwValue == pGlobalData->maxVolume)
227 {
228 pGlobalData->volumeCurrentValues[i].dwValue = dwVolume;
229 }
230 else
231 {
232 pGlobalData->volumeCurrentValues[i].dwValue =
233 pGlobalData->volumePreviousValues[i].dwValue * dwVolume / pGlobalData->maxVolume;
234 }
235 }
236
237 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
238 mxcd.dwControlID = pGlobalData->volumeControlID;
239 mxcd.cChannels = pGlobalData->volumeChannels;
240 mxcd.cMultipleItems = 0;
242 mxcd.paDetails = pGlobalData->volumeCurrentValues;
243
246 return;
247}
#define for
Definition: utility.h:88

Referenced by VolumeDlgProc().

◆ SwitchMuteState()

VOID SwitchMuteState ( PGLOBAL_DATA  pGlobalData)

Definition at line 97 of file volume.c.

98{
101
102 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
103 mxcd.dwControlID = pGlobalData->muteControlID;
104 mxcd.cChannels = 1;
105 mxcd.cMultipleItems = 0;
107 mxcd.paDetails = &mxcdMute;
108
109 mxcdMute.fValue = !pGlobalData->muteVal;
112 return;
113
114 pGlobalData->muteVal = mxcdMute.fValue;
115}

Referenced by VolumeDlgProc().

◆ VolumeDlgProc()

INT_PTR CALLBACK VolumeDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 388 of file volume.c.

392{
393 static const INT speakImgSize[] = {72, 72};
394 PGLOBAL_DATA pGlobalData;
395
396 pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
397
398 switch (uMsg)
399 {
401 {
402 GetMuteState(pGlobalData);
403 if (pGlobalData->muteVal)
404 {
407 }
408 else
409 {
412 }
413 break;
414 }
416 {
417 GetVolumeValue(pGlobalData, FALSE);
418 SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
419 break;
420 }
421 case WM_INITDIALOG:
422 {
424 SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
425
429 pGlobalData->hIconSpeakImg = LoadImageW(hApplet,
432 speakImgSize[0],
433 speakImgSize[1],
435
436 InitVolumeControls(hwndDlg, pGlobalData);
437 break;
438 }
439
440 case WM_DRAWITEM:
441 {
442 LPDRAWITEMSTRUCT lpDrawItem;
443 lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
444 if (lpDrawItem->CtlID == IDC_SPEAKIMG)
445 {
446 LONG left;
447
448 /* Position image in centre of dialog */
449 left = (lpDrawItem->rcItem.right - speakImgSize[0]) / 2;
450
451 DrawIconEx(lpDrawItem->hDC,
452 left,
453 lpDrawItem->rcItem.top,
454 pGlobalData->hIconSpeakImg,
455 speakImgSize[0],
456 speakImgSize[1],
457 0,
458 NULL,
459 DI_NORMAL);
460 }
461 break;
462 }
463
464 case WM_COMMAND:
465 {
466 switch (LOWORD(wParam))
467 {
469 if (HIWORD(wParam) == BN_CLICKED)
470 {
471 SwitchMuteState(pGlobalData);
472 if (pGlobalData->muteVal)
473 {
475 }
476 else
477 {
479 }
480
481 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
482 }
483 break;
484
486 if (HIWORD(wParam) == BN_CLICKED)
487 {
488 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
489 }
490 break;
491
492 case IDC_ADVANCED_BTN:
493 LaunchSoundControl(hwndDlg);
494 break;
495
497 SpeakerVolume(hwndDlg);
498 break;
499 }
500 break;
501 }
502
503 case WM_HSCROLL:
504 {
505 HWND hVolumeTrackbar = GetDlgItem(hwndDlg, IDC_VOLUME_TRACKBAR);
506 if (hVolumeTrackbar == (HWND)lParam)
507 {
508 switch (LOWORD(wParam))
509 {
510 case TB_THUMBPOSITION:
511 break;
512
513 case TB_ENDTRACK:
515 break;
516
517 default:
518 SetVolumeValue(pGlobalData,
520 break;
521 }
522 }
523 break;
524 }
525
526 case WM_DESTROY:
527 if (pGlobalData)
528 {
529 HeapFree(GetProcessHeap(), 0, pGlobalData->volumeCurrentValues);
530 HeapFree(GetProcessHeap(), 0, pGlobalData->volumePreviousValues);
531 HeapFree(GetProcessHeap(), 0, pGlobalData->volumeInitialValues);
532 mixerClose(pGlobalData->hMixer);
533
534 if (pGlobalData->hIconSpeakImg)
535 DestroyIcon(pGlobalData->hIconSpeakImg);
536
537 if (pGlobalData->hIconNoHW)
538 DestroyIcon(pGlobalData->hIconNoHW);
539
540 if (pGlobalData->hIconMuted)
541 DestroyIcon(pGlobalData->hIconMuted);
542
543 if (pGlobalData->hIconUnMuted)
544 DestroyIcon(pGlobalData->hIconUnMuted);
545
546 HeapFree(GetProcessHeap(), 0, pGlobalData);
547 }
548 break;
549
550 case WM_NOTIFY:
551 switch (((LPNMHDR)lParam)->code)
552 {
553 case PSN_APPLY:
554 SaveData(hwndDlg);
555 break;
556
557 case PSN_RESET:
558 RestoreVolumeValue(pGlobalData);
559 break;
560 }
561 return TRUE;
562 }
563
564 return FALSE;
565}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define IDI_CPLICON
Definition: resource.h:4
#define IDI_NO_HW
Definition: resource.h:13
#define IDC_SPEAKIMG
Definition: resource.h:70
#define IDI_MUTED_ICON
Definition: resource.h:14
#define IDI_SPEAKIMG
Definition: resource.h:69
struct _GLOBAL_DATA GLOBAL_DATA
static VOID RestoreVolumeValue(PGLOBAL_DATA pGlobalData)
Definition: volume.c:252
VOID SwitchMuteState(PGLOBAL_DATA pGlobalData)
Definition: volume.c:97
VOID InitVolumeControls(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
Definition: volume.c:302
struct _GLOBAL_DATA * PGLOBAL_DATA
VOID SetVolumeValue(PGLOBAL_DATA pGlobalData, DWORD dwPosition)
Definition: volume.c:208
VOID SaveData(HWND hwndDlg)
Definition: volume.c:368
VOID LaunchSoundControl(HWND hwndDlg)
Definition: volume.c:378
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLint left
Definition: glext.h:7726
INT_PTR SpeakerVolume(HWND hwndDlg)
#define SND_ALIAS_SYSTEMDEFAULT
Definition: mmsystem.h:175
#define MM_MIXM_CONTROL_CHANGE
Definition: mmsystem.h:83
#define MM_MIXM_LINE_CHANGE
Definition: mmsystem.h:82
#define SND_ALIAS_ID
Definition: mmsystem.h:161
#define SND_ASYNC
Definition: mmsystem.h:154
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
Definition: playsound.c:531
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_RESET
Definition: prsht.h:118
#define TB_ENDTRACK
Definition: commctrl.h:2081
#define TB_THUMBPOSITION
Definition: commctrl.h:2077
#define TBM_GETPOS
Definition: commctrl.h:2031
#define WM_NOTIFY
Definition: richedit.h:61
HICON hIconSpeakImg
Definition: volume.c:21
Definition: inflate.c:139
LONG right
Definition: windef.h:308
LONG top
Definition: windef.h:307
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define DI_NORMAL
Definition: wingdi.h:72
UINT WINAPI mixerClose(HMIXER hMix)
Definition: winmm.c:389
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define DWLP_USER
Definition: winuser.h:866
#define GetWindowLongPtrW
Definition: winuser.h:4819
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define WM_HSCROLL
Definition: winuser.h:1733
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_INITDIALOG
Definition: winuser.h:1729
#define WM_DRAWITEM
Definition: winuser.h:1635
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
HWND WINAPI GetParent(_In_ HWND)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1081
#define BN_CLICKED
Definition: winuser.h:1915
#define WM_DESTROY
Definition: winuser.h:1599
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SetWindowLongPtrW
Definition: winuser.h:5336
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by MmSysApplet(), and ShowFullControlPanel().