ReactOS  0.4.15-dev-1018-g0695ecb
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  _IMGINFO
 
struct  _GLOBAL_DATA
 

Typedefs

typedef struct _IMGINFO IMGINFO
 
typedef struct _IMGINFOPIMGINFO
 
typedef struct _GLOBAL_DATA GLOBAL_DATA
 
typedef struct _GLOBAL_DATAPGLOBAL_DATA
 

Functions

static VOID InitImageInfo (PIMGINFO ImgInfo)
 
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

◆ IMGINFO

◆ PGLOBAL_DATA

◆ PIMGINFO

Function Documentation

◆ GetMuteControl()

VOID GetMuteControl ( PGLOBAL_DATA  pGlobalData)

Definition at line 72 of file volume.c.

73 {
74  MIXERLINE mxln;
75  MIXERCONTROL mxc;
76  MIXERLINECONTROLS mxlctrl;
77 
78  if (pGlobalData->hMixer == NULL)
79  return;
80 
81  mxln.cbStruct = sizeof(MIXERLINE);
83 
85  != MMSYSERR_NOERROR) return;
86 
87  mxlctrl.cbStruct = sizeof(MIXERLINECONTROLS);
88  mxlctrl.dwLineID = mxln.dwLineID;
90  mxlctrl.cControls = 1;
91  mxlctrl.cbmxctrl = sizeof(MIXERCONTROL);
92  mxlctrl.pamxctrl = &mxc;
93 
95  != MMSYSERR_NOERROR) return;
96 
97  pGlobalData->muteControlID = mxc.dwControlID;
98 }
#define mixerGetLineInfo
Definition: mmsystem.h:2853
#define mixerGetLineControls
Definition: mmsystem.h:2854
#define MIXER_GETLINEINFOF_COMPONENTTYPE
Definition: mmsystem.h:347
MIXERLINEA MIXERLINE
Definition: mmsystem.h:2824
MIXERCONTROLA MIXERCONTROL
Definition: mmsystem.h:2825
LPMIXERCONTROLA pamxctrl
Definition: mmsystem.h:1338
MIXERLINECONTROLSA MIXERLINECONTROLS
Definition: mmsystem.h:2826
smooth NULL
Definition: ftsmooth.c:416
DWORD dwLineID
Definition: mmsystem.h:1235
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HMIXER hMixer
Definition: volume.c:25
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD muteControlID
Definition: volume.c:31
#define MIXERCONTROL_CONTROLTYPE_MUTE
Definition: mmsystem.h:384
#define MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
Definition: mmsystem.h:319
DWORD cbStruct
Definition: mmsystem.h:1232
#define MIXER_GETLINECONTROLSF_ONEBYTYPE
Definition: mmsystem.h:410
DWORD dwComponentType
Definition: mmsystem.h:1238

Referenced by InitVolumeControls().

◆ GetMuteState()

VOID GetMuteState ( PGLOBAL_DATA  pGlobalData)

Definition at line 102 of file volume.c.

103 {
105  MIXERCONTROLDETAILS mxcd;
106 
107  if (pGlobalData->hMixer == NULL)
108  return;
109 
110  mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
111  mxcd.dwControlID = pGlobalData->muteControlID;
112  mxcd.cChannels = 1;
113  mxcd.cMultipleItems = 0;
114  mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
115  mxcd.paDetails = &mxcdMute;
116 
118  != MMSYSERR_NOERROR)
119  return;
120 
121  pGlobalData->muteVal = mxcdMute.fValue;
122 }
#define MIXER_GETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:412
smooth NULL
Definition: ftsmooth.c:416
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HMIXER hMixer
Definition: volume.c:25
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD muteControlID
Definition: volume.c:31
struct tMIXERCONTROLDETAILS_BOOLEAN MIXERCONTROLDETAILS_BOOLEAN
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS
#define mixerGetControlDetails
Definition: mmsystem.h:2855
LONG muteVal
Definition: volume.c:30

Referenced by InitVolumeControls(), and VolumeDlgProc().

◆ GetSystrayVolumeIconState()

static BOOL GetSystrayVolumeIconState ( VOID  )
static

Definition at line 317 of file volume.c.

318 {
319  HWND hwndTaskBar;
320 
321  hwndTaskBar = FindWindowW(L"SystemTray_Main", NULL);
322  if (hwndTaskBar == NULL)
323  {
324  return FALSE;
325  }
326 
327  return (BOOL)SendMessageW(hwndTaskBar, WM_USER + 221, 4, 0);
328 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
static const WCHAR L[]
Definition: oid.c:1250
#define WM_USER
Definition: winuser.h:1877
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by InitVolumeControls().

◆ GetVolumeControl()

VOID GetVolumeControl ( PGLOBAL_DATA  pGlobalData)

Definition at line 148 of file volume.c.

149 {
150  MIXERLINE mxln;
151  MIXERCONTROL mxc;
152  MIXERLINECONTROLS mxlc;
153 
154  if (pGlobalData->hMixer == NULL)
155  return;
156 
157  mxln.cbStruct = sizeof(MIXERLINE);
160  != MMSYSERR_NOERROR)
161  return;
162 
163  pGlobalData->volumeChannels = mxln.cChannels;
164 
165  mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
166  mxlc.dwLineID = mxln.dwLineID;
168  mxlc.cControls = 1;
169  mxlc.cbmxctrl = sizeof(MIXERCONTROL);
170  mxlc.pamxctrl = &mxc;
172  != MMSYSERR_NOERROR)
173  return;
174 
175  pGlobalData->volumeMinimum = mxc.Bounds.dwMinimum;
176  pGlobalData->volumeMaximum = mxc.Bounds.dwMaximum;
177  pGlobalData->volumeControlID = mxc.dwControlID;
178  pGlobalData->volumeStep = (pGlobalData->volumeMaximum - pGlobalData->volumeMinimum) / (VOLUME_MAX - VOLUME_MIN);
179 
181  0,
182  mxln.cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED));
183  if (pGlobalData->volumeInitialValues == NULL)
184  return;
185 
187  0,
188  mxln.cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED));
189  if (pGlobalData->volumePreviousValues == NULL)
190  return;
191 
193  0,
194  mxln.cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED));
195  if (pGlobalData->volumeCurrentValues == NULL)
196  return;
197 }
PMIXERCONTROLDETAILS_UNSIGNED volumeInitialValues
Definition: volume.c:40
#define mixerGetLineInfo
Definition: mmsystem.h:2853
DWORD volumeMaximum
Definition: volume.c:36
#define mixerGetLineControls
Definition: mmsystem.h:2854
DWORD volumeMinimum
Definition: volume.c:35
#define VOLUME_MAX
Definition: sndvol32.h:19
#define MIXER_GETLINEINFOF_COMPONENTTYPE
Definition: mmsystem.h:347
DWORD volumeControlID
Definition: volume.c:33
MIXERLINEA MIXERLINE
Definition: mmsystem.h:2824
MIXERCONTROLA MIXERCONTROL
Definition: mmsystem.h:2825
PMIXERCONTROLDETAILS_UNSIGNED volumePreviousValues
Definition: volume.c:41
LPMIXERCONTROLA pamxctrl
Definition: mmsystem.h:1338
MIXERLINECONTROLSA MIXERLINECONTROLS
Definition: mmsystem.h:2826
smooth NULL
Definition: ftsmooth.c:416
DWORD dwLineID
Definition: mmsystem.h:1235
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HMIXER hMixer
Definition: volume.c:25
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD volumeChannels
Definition: volume.c:34
PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues
Definition: volume.c:42
DWORD cChannels
Definition: mmsystem.h:1239
#define MIXERCONTROL_CONTROLTYPE_VOLUME
Definition: mmsystem.h:398
#define MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
Definition: mmsystem.h:319
DWORD volumeStep
Definition: volume.c:37
DWORD cbStruct
Definition: mmsystem.h:1232
union tagMIXERCONTROLA::@2992 Bounds
#define VOLUME_MIN
Definition: sndvol32.h:18
#define MIXER_GETLINECONTROLSF_ONEBYTYPE
Definition: mmsystem.h:410
DWORD dwComponentType
Definition: mmsystem.h:1238

Referenced by InitVolumeControls().

◆ GetVolumeValue()

VOID GetVolumeValue ( PGLOBAL_DATA  pGlobalData,
BOOL  bInit 
)

Definition at line 201 of file volume.c.

204 {
205  MIXERCONTROLDETAILS mxcd;
206  DWORD i;
207 
208  if (pGlobalData->hMixer == NULL)
209  return;
210 
211  mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
212  mxcd.dwControlID = pGlobalData->volumeControlID;
213  mxcd.cChannels = pGlobalData->volumeChannels;
214  mxcd.cMultipleItems = 0;
216  mxcd.paDetails = pGlobalData->volumePreviousValues;
217 
219  != MMSYSERR_NOERROR)
220  return;
221 
222  pGlobalData->maxVolume = 0;
223  for (i = 0; i < pGlobalData->volumeChannels; i++)
224  {
225  pGlobalData->volumeCurrentValues[i].dwValue = pGlobalData->volumePreviousValues[i].dwValue;
226 
227  if (pGlobalData->volumePreviousValues[i].dwValue > pGlobalData->maxVolume)
228  pGlobalData->maxVolume = pGlobalData->volumePreviousValues[i].dwValue;
229 
230  if (bInit)
231  pGlobalData->volumeInitialValues[i].dwValue = pGlobalData->volumeCurrentValues[i].dwValue;
232  }
233 }
PMIXERCONTROLDETAILS_UNSIGNED volumeInitialValues
Definition: volume.c:40
#define MIXER_GETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:412
struct tMIXERCONTROLDETAILS_UNSIGNED MIXERCONTROLDETAILS_UNSIGNED
DWORD maxVolume
Definition: volume.c:39
DWORD volumeControlID
Definition: volume.c:33
PMIXERCONTROLDETAILS_UNSIGNED volumePreviousValues
Definition: volume.c:41
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
smooth NULL
Definition: ftsmooth.c:416
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HMIXER hMixer
Definition: volume.c:25
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD volumeChannels
Definition: volume.c:34
PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues
Definition: volume.c:42
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS
#define mixerGetControlDetails
Definition: mmsystem.h:2855

Referenced by InitVolumeControls(), and VolumeDlgProc().

◆ InitImageInfo()

static VOID InitImageInfo ( PIMGINFO  ImgInfo)
static

Definition at line 48 of file volume.c.

49 {
50  BITMAP bitmap;
51 
52  ZeroMemory(ImgInfo, sizeof(*ImgInfo));
53 
54  ImgInfo->hBitmap = LoadImage(hApplet,
57  0,
58  0,
60 
61  if (ImgInfo->hBitmap != NULL)
62  {
63  GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
64 
65  ImgInfo->cxSource = bitmap.bmWidth;
66  ImgInfo->cySource = bitmap.bmHeight;
67  }
68 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ZeroMemory
Definition: winbase.h:1648
#define IDB_SPEAKIMG
Definition: resource.h:69
HINSTANCE hApplet
Definition: access.c:17
smooth NULL
Definition: ftsmooth.c:416
INT cySource
Definition: userinit.h:51
Definition: uimain.c:88
#define GetObject
Definition: wingdi.h:4467
INT cxSource
Definition: userinit.h:50
Definition: bl.h:1331
HBITMAP hBitmap
Definition: userinit.h:49
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LoadImage
Definition: winuser.h:5790
static HBITMAP bitmap
Definition: clipboard.c:1344
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077

Referenced by VolumeDlgProc().

◆ InitVolumeControls()

VOID InitVolumeControls ( HWND  hwndDlg,
PGLOBAL_DATA  pGlobalData 
)

Definition at line 331 of file volume.c.

332 {
333  UINT NumMixers;
334  MIXERCAPS mxc;
335  TCHAR szNoDevices[256];
336 
337  LoadString(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
338 
342 
343  NumMixers = mixerGetNumDevs();
344  if (!NumMixers)
345  {
355  SetDlgItemText(hwndDlg, IDC_DEVICE_NAME, szNoDevices);
356  return;
357  }
358 
359  if (mixerOpen(&pGlobalData->hMixer, 0, PtrToUlong(hwndDlg), 0, MIXER_OBJECTF_MIXER | CALLBACK_WINDOW) != MMSYSERR_NOERROR)
360  {
361  MessageBox(hwndDlg, _T("Cannot open mixer"), NULL, MB_OK);
362  return;
363  }
364 
365  ZeroMemory(&mxc, sizeof(MIXERCAPS));
366  if (mixerGetDevCaps(PtrToUint(pGlobalData->hMixer), &mxc, sizeof(MIXERCAPS)) != MMSYSERR_NOERROR)
367  {
368  MessageBox(hwndDlg, _T("mixerGetDevCaps failed"), NULL, MB_OK);
369  return;
370  }
371 
372  CheckDlgButton(hwndDlg,
375 
376  GetMuteControl(pGlobalData);
377  GetMuteState(pGlobalData);
378  if (pGlobalData->muteVal)
379  {
382  }
383  else
384  {
387  }
388 
389  GetVolumeControl(pGlobalData);
390  GetVolumeValue(pGlobalData, TRUE);
391 
393  SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
394 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define PtrToUint(p)
Definition: basetsd.h:85
#define IMAGE_ICON
Definition: winuser.h:212
#define CALLBACK_WINDOW
Definition: mmsystem.h:148
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1217
HICON hIconNoHW
Definition: volume.c:28
#define TRUE
Definition: types.h:120
static BOOL GetSystrayVolumeIconState(VOID)
Definition: volume.c:317
#define TBM_SETRANGE
Definition: commctrl.h:2033
DWORD maxVolume
Definition: volume.c:39
#define IDC_VOLUME_LOW
Definition: resource.h:34
#define ZeroMemory
Definition: winbase.h:1648
DWORD volumeMinimum
Definition: volume.c:35
#define TBM_SETPOS
Definition: commctrl.h:2032
#define VOLUME_MAX
Definition: sndvol32.h:19
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5817
#define IDC_VOLUME_HIGH
Definition: resource.h:35
VOID GetVolumeValue(PGLOBAL_DATA pGlobalData, BOOL bInit)
Definition: volume.c:201
#define mixerGetDevCaps
Definition: mmsystem.h:2852
#define MIXER_OBJECTF_MIXER
Definition: mmsystem.h:300
#define FALSE
Definition: types.h:117
#define IDC_VOLUME_TRACKBAR
Definition: resource.h:33
VOID GetMuteState(PGLOBAL_DATA pGlobalData)
Definition: volume.c:102
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define TBM_SETPAGESIZE
Definition: commctrl.h:2047
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
UINT WINAPI mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
Definition: winmm.c:342
#define TBM_SETTICFREQ
Definition: commctrl.h:2046
#define IDC_ICON_IN_TASKBAR
Definition: resource.h:37
#define VOLUME_PAGESIZE
Definition: mmsys.h:43
#define WM_SETTEXT
Definition: winuser.h:1599
#define PtrToUlong(u)
Definition: config.h:107
#define IDC_ADVANCED_BTN
Definition: resource.h:51
char TCHAR
Definition: xmlstorage.h:189
#define BM_SETCHECK
Definition: winuser.h:1903
#define _T(x)
Definition: vfdio.h:22
HICON hIconMuted
Definition: volume.c:26
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HMIXER hMixer
Definition: volume.c:25
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define VOLUME_TICFREQ
Definition: mmsys.h:42
#define _countof(array)
Definition: sndvol32.h:68
#define IDS_NO_DEVICES
Definition: resource.h:91
#define SetDlgItemText
Definition: winuser.h:5824
#define IDC_DEVICE_NAME
Definition: resource.h:50
#define IDC_ADVANCED2_BTN
Definition: resource.h:54
#define MessageBox
Definition: winuser.h:5797
#define BST_UNCHECKED
Definition: winuser.h:199
HICON hIconUnMuted
Definition: volume.c:27
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
DWORD volumeStep
Definition: volume.c:37
UINT WINAPI mixerGetNumDevs(void)
Definition: winmm.c:283
#define VOLUME_MIN
Definition: sndvol32.h:18
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
#define STM_SETIMAGE
Definition: winuser.h:2075
#define BST_CHECKED
Definition: winuser.h:197
#define IDC_MUTE_CHECKBOX
Definition: resource.h:36
LONG muteVal
Definition: volume.c:30
#define IDC_MUTE_ICON
Definition: resource.h:71
VOID GetVolumeControl(PGLOBAL_DATA pGlobalData)
Definition: volume.c:148
#define IDC_SPEAKER_VOL_BTN
Definition: resource.h:53
#define LoadString
Definition: winuser.h:5794
VOID GetMuteControl(PGLOBAL_DATA pGlobalData)
Definition: volume.c:72

Referenced by VolumeDlgProc().

◆ LaunchSoundControl()

VOID LaunchSoundControl ( HWND  hwndDlg)

Definition at line 407 of file volume.c.

408 {
409  if ((INT_PTR)ShellExecuteW(NULL, L"open", L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL) > 32)
410  return;
411  MessageBox(hwndDlg, _T("Cannot run sndvol32.exe"), NULL, MB_OK);
412 }
int32_t INT_PTR
Definition: typedefs.h:64
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
static const WCHAR L[]
Definition: oid.c:1250
#define MessageBox
Definition: winuser.h:5797
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define MB_OK
Definition: winuser.h:784
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274

Referenced by VolumeDlgProc().

◆ RestoreVolumeValue()

static VOID RestoreVolumeValue ( PGLOBAL_DATA  pGlobalData)
static

Definition at line 281 of file volume.c.

283 {
284  MIXERCONTROLDETAILS mxcd;
285 
286  if (pGlobalData->hMixer == NULL)
287  return;
288 
289  mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
290  mxcd.dwControlID = pGlobalData->volumeControlID;
291  mxcd.cChannels = pGlobalData->volumeChannels;
292  mxcd.cMultipleItems = 0;
294  mxcd.paDetails = pGlobalData->volumeInitialValues;
295 
296  mixerSetControlDetails((HMIXEROBJ)pGlobalData->hMixer,
297  &mxcd,
299 }
PMIXERCONTROLDETAILS_UNSIGNED volumeInitialValues
Definition: volume.c:40
UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
Definition: winmm.c:684
struct tMIXERCONTROLDETAILS_UNSIGNED MIXERCONTROLDETAILS_UNSIGNED
DWORD volumeControlID
Definition: volume.c:33
#define MIXER_SETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:415
smooth NULL
Definition: ftsmooth.c:416
HMIXER hMixer
Definition: volume.c:25
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD volumeChannels
Definition: volume.c:34
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS

Referenced by VolumeDlgProc().

◆ SaveData()

VOID SaveData ( HWND  hwndDlg)

Definition at line 397 of file volume.c.

398 {
399  BOOL bShowIcon;
400 
401  bShowIcon = (IsDlgButtonChecked(hwndDlg, IDC_ICON_IN_TASKBAR) == BST_CHECKED);
402 
403  SetSystrayVolumeIconState(bShowIcon);
404 }
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_ICON_IN_TASKBAR
Definition: resource.h:37
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
static VOID SetSystrayVolumeIconState(BOOL bEnabled)
Definition: volume.c:304
#define BST_CHECKED
Definition: winuser.h:197

Referenced by DECLARE_INTERFACE_(), and VolumeDlgProc().

◆ SetSystrayVolumeIconState()

static VOID SetSystrayVolumeIconState ( BOOL  bEnabled)
static

Definition at line 304 of file volume.c.

305 {
306  HWND hwndTaskBar;
307 
308  hwndTaskBar = FindWindowW(L"SystemTray_Main", NULL);
309  if (hwndTaskBar == NULL)
310  return;
311 
312  SendMessageW(hwndTaskBar, WM_USER + 220, 4, bEnabled);
313 }
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
static const WCHAR L[]
Definition: oid.c:1250
#define WM_USER
Definition: winuser.h:1877
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by SaveData().

◆ SetVolumeValue()

VOID SetVolumeValue ( PGLOBAL_DATA  pGlobalData,
DWORD  dwPosition 
)

Definition at line 237 of file volume.c.

239 {
240  MIXERCONTROLDETAILS mxcd;
241  DWORD dwVolume, i;
242 
243  if (pGlobalData->hMixer == NULL)
244  return;
245 
246  if (dwPosition == VOLUME_MIN)
247  dwVolume = pGlobalData->volumeMinimum;
248  else if (dwPosition == VOLUME_MAX)
249  dwVolume = pGlobalData->volumeMaximum;
250  else
251  dwVolume = (dwPosition * pGlobalData->volumeStep) + pGlobalData->volumeMinimum;
252 
253  for (i = 0; i < pGlobalData->volumeChannels; i++)
254  {
255  if (pGlobalData->volumePreviousValues[i].dwValue == pGlobalData->maxVolume)
256  {
257  pGlobalData->volumeCurrentValues[i].dwValue = dwVolume;
258  }
259  else
260  {
261  pGlobalData->volumeCurrentValues[i].dwValue =
262  pGlobalData->volumePreviousValues[i].dwValue * dwVolume / pGlobalData-> maxVolume;
263  }
264  }
265 
266  mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
267  mxcd.dwControlID = pGlobalData->volumeControlID;
268  mxcd.cChannels = pGlobalData->volumeChannels;
269  mxcd.cMultipleItems = 0;
271  mxcd.paDetails = pGlobalData->volumeCurrentValues;
272 
274  != MMSYSERR_NOERROR)
275  return;
276 }
UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
Definition: winmm.c:684
struct tMIXERCONTROLDETAILS_UNSIGNED MIXERCONTROLDETAILS_UNSIGNED
DWORD volumeMaximum
Definition: volume.c:36
DWORD maxVolume
Definition: volume.c:39
DWORD volumeMinimum
Definition: volume.c:35
#define VOLUME_MAX
Definition: sndvol32.h:19
DWORD volumeControlID
Definition: volume.c:33
PMIXERCONTROLDETAILS_UNSIGNED volumePreviousValues
Definition: volume.c:41
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
#define MIXER_SETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:415
smooth NULL
Definition: ftsmooth.c:416
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HMIXER hMixer
Definition: volume.c:25
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD volumeChannels
Definition: volume.c:34
PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues
Definition: volume.c:42
DWORD volumeStep
Definition: volume.c:37
#define VOLUME_MIN
Definition: sndvol32.h:18
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS

Referenced by VolumeDlgProc().

◆ SwitchMuteState()

VOID SwitchMuteState ( PGLOBAL_DATA  pGlobalData)

Definition at line 126 of file volume.c.

127 {
129  MIXERCONTROLDETAILS mxcd;
130 
131  mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
132  mxcd.dwControlID = pGlobalData->muteControlID;
133  mxcd.cChannels = 1;
134  mxcd.cMultipleItems = 0;
135  mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
136  mxcd.paDetails = &mxcdMute;
137 
138  mxcdMute.fValue = !pGlobalData->muteVal;
140  != MMSYSERR_NOERROR)
141  return;
142 
143  pGlobalData->muteVal = mxcdMute.fValue;
144 }
UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
Definition: winmm.c:684
#define MIXER_SETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:415
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
HMIXER hMixer
Definition: volume.c:25
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
DWORD muteControlID
Definition: volume.c:31
struct tMIXERCONTROLDETAILS_BOOLEAN MIXERCONTROLDETAILS_BOOLEAN
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS
LONG muteVal
Definition: volume.c:30

Referenced by VolumeDlgProc().

◆ VolumeDlgProc()

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

Definition at line 417 of file volume.c.

421 {
422  static IMGINFO ImgInfo;
423  PGLOBAL_DATA pGlobalData;
426 
427  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
428 
429  switch(uMsg)
430  {
431  case MM_MIXM_LINE_CHANGE:
432  {
433  GetMuteState(pGlobalData);
434  if (pGlobalData->muteVal)
435  {
438  }
439  else
440  {
443  }
444  break;
445  }
447  {
448  GetVolumeValue(pGlobalData, FALSE);
449  SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
450  break;
451  }
452  case WM_INITDIALOG:
453  {
454  pGlobalData = (GLOBAL_DATA*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
455  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
456 
460 
461  InitImageInfo(&ImgInfo);
462  InitVolumeControls(hwndDlg, pGlobalData);
463  break;
464  }
465 
466  case WM_DRAWITEM:
467  {
468  LPDRAWITEMSTRUCT lpDrawItem;
469  lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
470  if(lpDrawItem->CtlID == IDC_SPEAKIMG)
471  {
472  HDC hdcMem;
473  LONG left;
474 
475  /* Position image in centre of dialog */
476  left = (lpDrawItem->rcItem.right - ImgInfo.cxSource) / 2;
477 
478  hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
479  if (hdcMem != NULL)
480  {
481  SelectObject(hdcMem, ImgInfo.hBitmap);
482  BitBlt(lpDrawItem->hDC,
483  left,
484  lpDrawItem->rcItem.top,
485  lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
486  lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
487  hdcMem,
488  0,
489  0,
490  SRCCOPY);
491  DeleteDC(hdcMem);
492  }
493  }
494  break;
495  }
496 
497  case WM_COMMAND:
498  {
499  switch (LOWORD(wParam))
500  {
501  case IDC_MUTE_CHECKBOX:
502  if (HIWORD(wParam) == BN_CLICKED)
503  {
504  SwitchMuteState(pGlobalData);
505  if (pGlobalData->muteVal)
506  {
508  }
509  else
510  {
512  }
513 
514  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
515  }
516  break;
517 
518  case IDC_ICON_IN_TASKBAR:
519  if (HIWORD(wParam) == BN_CLICKED)
520  {
521  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
522  }
523  break;
524 
525  case IDC_ADVANCED_BTN:
526  LaunchSoundControl(hwndDlg);
527  break;
528 
529  case IDC_SPEAKER_VOL_BTN:
530  SpeakerVolume(hwndDlg);
531  break;
532  }
533  break;
534  }
535 
536  case WM_HSCROLL:
537  {
538  HWND hVolumeTrackbar = GetDlgItem(hwndDlg, IDC_VOLUME_TRACKBAR);
539  if (hVolumeTrackbar == (HWND)lParam)
540  {
541  switch (LOWORD(wParam))
542  {
543  case TB_THUMBPOSITION:
544  break;
545 
546  case TB_ENDTRACK:
548  break;
549 
550  default:
551  SetVolumeValue(pGlobalData,
553  break;
554  }
555  }
556  break;
557  }
558 
559  case WM_DESTROY:
560  if (pGlobalData)
561  {
562  if (pGlobalData->volumeCurrentValues)
563  HeapFree(GetProcessHeap(), 0, pGlobalData->volumeCurrentValues);
564 
565  if (pGlobalData->volumePreviousValues)
566  HeapFree(GetProcessHeap(), 0, pGlobalData->volumePreviousValues);
567 
568  if (pGlobalData->volumeInitialValues)
569  HeapFree(GetProcessHeap(), 0, pGlobalData->volumeInitialValues);
570 
571  mixerClose(pGlobalData->hMixer);
572  DestroyIcon(pGlobalData->hIconMuted);
573  DestroyIcon(pGlobalData->hIconUnMuted);
574  DestroyIcon(pGlobalData->hIconNoHW);
575  HeapFree(GetProcessHeap(), 0, pGlobalData);
576  }
577  break;
578 
579  case WM_NOTIFY:
580  switch (((LPNMHDR)lParam)->code)
581  {
582  case PSN_APPLY:
583  SaveData(hwndDlg);
584  break;
585 
586  case PSN_RESET:
587  RestoreVolumeValue(pGlobalData);
588  break;
589  }
590  return TRUE;
591  }
592 
593  return FALSE;
594 }
PMIXERCONTROLDETAILS_UNSIGNED volumeInitialValues
Definition: volume.c:40
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define SND_ALIAS_ID
Definition: mmsystem.h:161
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IMAGE_ICON
Definition: winuser.h:212
static VOID InitImageInfo(PIMGINFO ImgInfo)
Definition: volume.c:48
#define IDI_MUTED_ICON
Definition: resource.h:14
HICON hIconNoHW
Definition: volume.c:28
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
struct _GLOBAL_DATA * PGLOBAL_DATA
static HDC
Definition: imagelist.c:92
VOID LaunchSoundControl(HWND hwndDlg)
Definition: volume.c:407
UINT WINAPI mixerClose(HMIXER hMix)
Definition: winmm.c:389
DWORD maxVolume
Definition: volume.c:39
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
DWORD volumeMinimum
Definition: volume.c:35
#define TBM_SETPOS
Definition: commctrl.h:2032
HINSTANCE hApplet
Definition: access.c:17
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5817
#define PSN_APPLY
Definition: prsht.h:117
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
VOID SetVolumeValue(PGLOBAL_DATA pGlobalData, DWORD dwPosition)
Definition: volume.c:237
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
VOID GetVolumeValue(PGLOBAL_DATA pGlobalData, BOOL bInit)
Definition: volume.c:201
PMIXERCONTROLDETAILS_UNSIGNED volumePreviousValues
Definition: volume.c:41
#define FALSE
Definition: types.h:117
VOID InitVolumeControls(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
Definition: volume.c:331
long LONG
Definition: pedump.c:60
#define IDC_VOLUME_TRACKBAR
Definition: resource.h:33
#define TBM_GETPOS
Definition: commctrl.h:2027
VOID GetMuteState(PGLOBAL_DATA pGlobalData)
Definition: volume.c:102
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_ICON_IN_TASKBAR
Definition: resource.h:37
#define WM_DESTROY
Definition: winuser.h:1591
#define SND_ALIAS_SYSTEMDEFAULT
Definition: mmsystem.h:175
#define IDC_ADVANCED_BTN
Definition: resource.h:51
#define BM_SETCHECK
Definition: winuser.h:1903
struct _GLOBAL_DATA GLOBAL_DATA
HICON hIconMuted
Definition: volume.c:26
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HMIXER hMixer
Definition: volume.c:25
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
#define IDI_CPLICON
Definition: resource.h:4
#define SND_ASYNC
Definition: mmsystem.h:154
INT_PTR SpeakerVolume(HWND hwndDlg)
#define TB_ENDTRACK
Definition: commctrl.h:2077
PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues
Definition: volume.c:42
#define IDI_NO_HW
Definition: resource.h:13
#define DWLP_USER
Definition: winuser.h:866
static VOID RestoreVolumeValue(PGLOBAL_DATA pGlobalData)
Definition: volume.c:281
#define WM_COMMAND
Definition: winuser.h:1722
Definition: inflate.c:139
#define BST_UNCHECKED
Definition: winuser.h:199
HICON hIconUnMuted
Definition: volume.c:27
INT cxSource
Definition: userinit.h:50
HWND WINAPI GetParent(_In_ HWND)
#define PlaySound
Definition: mmsystem.h:2842
BOOL WINAPI DeleteDC(_In_ HDC)
DWORD volumeStep
Definition: volume.c:37
#define PSN_RESET
Definition: prsht.h:118
HBITMAP hBitmap
Definition: userinit.h:49
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_HSCROLL
Definition: winuser.h:1725
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define STM_SETIMAGE
Definition: winuser.h:2075
#define BST_CHECKED
Definition: winuser.h:197
#define WM_DRAWITEM
Definition: winuser.h:1627
#define IDC_MUTE_CHECKBOX
Definition: resource.h:36
#define HIWORD(l)
Definition: typedefs.h:247
LONG bottom
Definition: windef.h:309
LONG muteVal
Definition: volume.c:30
#define LoadImage
Definition: winuser.h:5790
#define IDC_SPEAKIMG
Definition: resource.h:70
#define MM_MIXM_LINE_CHANGE
Definition: mmsystem.h:82
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDC_MUTE_ICON
Definition: resource.h:71
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
#define TB_THUMBPOSITION
Definition: commctrl.h:2073
#define WM_INITDIALOG
Definition: winuser.h:1721
VOID SaveData(HWND hwndDlg)
Definition: volume.c:397
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_SPEAKER_VOL_BTN
Definition: resource.h:53
#define HeapFree(x, y, z)
Definition: compat.h:483
#define SRCCOPY
Definition: wingdi.h:332
HDC hdcMem
Definition: welcome.c:104
#define WM_NOTIFY
Definition: richedit.h:61
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
VOID SwitchMuteState(PGLOBAL_DATA pGlobalData)
Definition: volume.c:126
#define MM_MIXM_CONTROL_CHANGE
Definition: mmsystem.h:83

Referenced by MmSysApplet().