ReactOS 0.4.15-dev-8344-g0574987
tray.c File Reference
#include "sndvol32.h"
Include dependency graph for tray.c:

Go to the source code of this file.

Classes

struct  _DIALOG_DATA
 

Typedefs

typedef struct _DIALOG_DATA DIALOG_DATA
 
typedef struct _DIALOG_DATAPDIALOG_DATA
 

Functions

static VOID OnTrayInitDialog (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static VOID OnTrayInitMixer (PDIALOG_DATA pDialogData, HWND hwndDlg)
 
static VOID OnCommand (PDIALOG_DATA pDialogData, HWND hwndDlg, WPARAM wParam, LPARAM lParam)
 
static VOID OnVScroll (PDIALOG_DATA pDialogData, HWND hwndDlg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK TrayDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ DIALOG_DATA

◆ PDIALOG_DATA

Function Documentation

◆ OnCommand()

static VOID OnCommand ( PDIALOG_DATA  pDialogData,
HWND  hwndDlg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 173 of file tray.c.

178{
181
182 if ((LOWORD(wParam) == IDC_LINE_SWITCH) &&
184 {
185 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
186 mxcd.dwControlID = pDialogData->muteControlID;
187 mxcd.cChannels = 1;
188 mxcd.cMultipleItems = 0;
190 mxcd.paDetails = &mxcdMute;
191
192 mxcdMute.fValue = (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED);
193
194 mixerSetControlDetails((HMIXEROBJ)pDialogData->hMixer,
195 &mxcd,
197 }
198}
#define IDC_LINE_SWITCH
Definition: resources.h:23
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define MIXER_SETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:415
struct tMIXERCONTROLDETAILS_BOOLEAN MIXERCONTROLDETAILS_BOOLEAN
struct tMIXERCONTROLDETAILS MIXERCONTROLDETAILS
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
#define LOWORD(l)
Definition: pedump.c:82
DWORD muteControlID
Definition: tray.c:24
HMIXER hMixer
Definition: tray.c:12
#define HIWORD(l)
Definition: typedefs.h:247
UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd, DWORD fdwDetails)
Definition: winmm.c:681
#define SendMessage
Definition: winuser.h:5852
#define BN_CLICKED
Definition: winuser.h:1925
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918

Referenced by TrayDlgProc().

◆ OnTrayInitDialog()

static VOID OnTrayInitDialog ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 29 of file tray.c.

33{
34 POINT ptCursor;
35 RECT rcWindow;
36 RECT rcScreen;
37 LONG x, y, cx, cy;
38
39 GetCursorPos(&ptCursor);
40
41 GetWindowRect(hwnd, &rcWindow);
42
43 GetWindowRect(GetDesktopWindow(), &rcScreen);
44
45 cx = rcWindow.right - rcWindow.left;
46 cy = rcWindow.bottom - rcWindow.top;
47
48 if (ptCursor.y + cy > rcScreen.bottom)
49 y = ptCursor.y - cy;
50 else
51 y = ptCursor.y;
52
53 if (ptCursor.x + cx > rcScreen.right)
54 x = ptCursor.x - cx;
55 else
56 x = ptCursor.x;
57
59}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
long LONG
Definition: pedump.c:60
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HWND_TOPMOST
Definition: winuser.h:1208
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2714
#define SWP_NOSIZE
Definition: winuser.h:1245
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628

Referenced by TrayDlgProc().

◆ OnTrayInitMixer()

static VOID OnTrayInitMixer ( PDIALOG_DATA  pDialogData,
HWND  hwndDlg 
)
static

Definition at line 64 of file tray.c.

67{
68 MIXERLINE mxln;
69 MIXERCONTROL mxc;
70 MIXERLINECONTROLS mxlctrl;
73 DWORD i;
74
75 /* Open the mixer */
76 if (mixerOpen(&pDialogData->hMixer, 0, PtrToUlong(hwndDlg), 0, MIXER_OBJECTF_MIXER | CALLBACK_WINDOW) != MMSYSERR_NOERROR)
77 return;
78
79 /* Retrieve the mixer information */
80 mxln.cbStruct = sizeof(MIXERLINE);
82
84 return;
85
86 pDialogData->volumeChannels = mxln.cChannels;
87
88 /* Retrieve the line information */
89 mxlctrl.cbStruct = sizeof(MIXERLINECONTROLS);
90 mxlctrl.dwLineID = mxln.dwLineID;
92 mxlctrl.cControls = 1;
93 mxlctrl.cbmxctrl = sizeof(MIXERCONTROL);
94 mxlctrl.pamxctrl = &mxc;
95
97 return;
98
99 pDialogData->volumeControlID = mxc.dwControlID;
100 pDialogData->volumeMinimum = mxc.Bounds.dwMinimum;
101 pDialogData->volumeMaximum = mxc.Bounds.dwMaximum;
102 pDialogData->volumeStep = (pDialogData->volumeMaximum - pDialogData->volumeMinimum) / (VOLUME_MAX - VOLUME_MIN);
103
104 /* Allocate a buffer for all channel volume values */
106 0,
108 if (pDialogData->volumeInitValues == NULL)
109 return;
110
112 0,
114 if (pDialogData->volumeCurrentValues == NULL)
115 return;
116
117 /* Retrieve the channel volume values */
118 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
119 mxcd.dwControlID = mxc.dwControlID;
120 mxcd.cChannels = mxln.cChannels;
121 mxcd.cMultipleItems = 0;
123 mxcd.paDetails = pDialogData->volumeInitValues;
124
126 return;
127
128 pDialogData->maxVolume = 0;
129 for (i = 0; i < pDialogData->volumeChannels; i++)
130 {
131 pDialogData->volumeCurrentValues[i].dwValue = pDialogData->volumeInitValues[i].dwValue;
132
133 if (pDialogData->volumeInitValues[i].dwValue > pDialogData->maxVolume)
134 pDialogData->maxVolume = pDialogData->volumeInitValues[i].dwValue;
135 }
136
137 /* Initialize the volume trackbar */
140 SendDlgItemMessage(hwndDlg, IDC_LINE_SLIDER_VERT, TBM_SETPOS, TRUE, VOLUME_MAX -(pDialogData->maxVolume - pDialogData->volumeMinimum) / pDialogData->volumeStep);
141
142 /* Retrieve the mute control information */
143 mxlctrl.cbStruct = sizeof(MIXERLINECONTROLS);
144 mxlctrl.dwLineID = mxln.dwLineID;
146 mxlctrl.cControls = 1;
147 mxlctrl.cbmxctrl = sizeof(MIXERCONTROL);
148 mxlctrl.pamxctrl = &mxc;
149
151 return;
152
153 pDialogData->muteControlID = mxc.dwControlID;
154
155 /* Retrieve the mute value */
156 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
157 mxcd.dwControlID = mxc.dwControlID;
158 mxcd.cChannels = 1;
159 mxcd.cMultipleItems = 0;
161 mxcd.paDetails = &mxcdBool;
162
164 return;
165
166 /* Initialize the mute checkbox */
168}
#define IDC_LINE_SLIDER_VERT
Definition: resources.h:25
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define PtrToUlong(u)
Definition: config.h:107
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
#define CALLBACK_WINDOW
Definition: mmsystem.h:148
#define MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
Definition: mmsystem.h:319
#define MIXER_OBJECTF_MIXER
Definition: mmsystem.h:300
MIXERCONTROLA MIXERCONTROL
Definition: mmsystem.h:2825
MIXERLINECONTROLSA MIXERLINECONTROLS
Definition: mmsystem.h:2826
#define MIXER_GETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:412
#define mixerGetControlDetails
Definition: mmsystem.h:2855
#define mixerGetLineControls
Definition: mmsystem.h:2854
#define MIXERCONTROL_CONTROLTYPE_VOLUME
Definition: mmsystem.h:398
MIXERLINEA MIXERLINE
Definition: mmsystem.h:2824
#define MIXER_GETLINEINFOF_COMPONENTTYPE
Definition: mmsystem.h:347
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define mixerGetLineInfo
Definition: mmsystem.h:2853
struct tMIXERCONTROLDETAILS_UNSIGNED MIXERCONTROLDETAILS_UNSIGNED
#define MIXER_GETLINECONTROLSF_ONEBYTYPE
Definition: mmsystem.h:410
#define MIXERCONTROL_CONTROLTYPE_MUTE
Definition: mmsystem.h:384
#define TBM_SETPAGESIZE
Definition: commctrl.h:2051
#define TBM_SETRANGE
Definition: commctrl.h:2037
#define TBM_SETPOS
Definition: commctrl.h:2036
#define VOLUME_MAX
Definition: sndvol32.h:19
#define VOLUME_PAGE_SIZE
Definition: sndvol32.h:21
#define VOLUME_MIN
Definition: sndvol32.h:18
DWORD volumeChannels
Definition: tray.c:14
DWORD volumeStep
Definition: tray.c:17
DWORD volumeControlID
Definition: tray.c:13
PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues
Definition: tray.c:22
PMIXERCONTROLDETAILS_UNSIGNED volumeInitValues
Definition: tray.c:21
DWORD volumeMaximum
Definition: tray.c:16
DWORD maxVolume
Definition: tray.c:19
DWORD volumeMinimum
Definition: tray.c:15
union tagMIXERCONTROLA::@3059 Bounds
DWORD dwComponentType
Definition: mmsystem.h:1238
DWORD dwLineID
Definition: mmsystem.h:1235
DWORD cbStruct
Definition: mmsystem.h:1232
DWORD cChannels
Definition: mmsystem.h:1239
LPMIXERCONTROLA pamxctrl
Definition: mmsystem.h:1338
#define MAKELONG(a, b)
Definition: typedefs.h:249
UINT_PTR WPARAM
Definition: windef.h:207
UINT WINAPI mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
Definition: winmm.c:339
#define BST_UNCHECKED
Definition: winuser.h:199
#define BM_SETCHECK
Definition: winuser.h:1921
#define SendDlgItemMessage
Definition: winuser.h:5851

Referenced by TrayDlgProc().

◆ OnVScroll()

static VOID OnVScroll ( PDIALOG_DATA  pDialogData,
HWND  hwndDlg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 203 of file tray.c.

208{
210 DWORD dwPosition, dwVolume, i;
211
212 switch (LOWORD(wParam))
213 {
214 case TB_THUMBPOSITION:
215 break;
216
217 case TB_ENDTRACK:
219 break;
220
221 default:
222 dwPosition = VOLUME_MAX - (DWORD)SendDlgItemMessage(hwndDlg, IDC_LINE_SLIDER_VERT, TBM_GETPOS, 0, 0);
223
224 if (dwPosition == VOLUME_MIN)
225 dwVolume = pDialogData->volumeMinimum;
226 else if (dwPosition == VOLUME_MAX)
227 dwVolume = pDialogData->volumeMaximum;
228 else
229 dwVolume = (dwPosition * pDialogData->volumeStep) + pDialogData->volumeMinimum;
230
231 for (i = 0; i < pDialogData->volumeChannels; i++)
232 {
233 if (pDialogData->volumeInitValues[i].dwValue == pDialogData->maxVolume)
234 {
235 pDialogData->volumeCurrentValues[i].dwValue = dwVolume;
236 }
237 else
238 {
239 pDialogData->volumeCurrentValues[i].dwValue =
240 pDialogData->volumeInitValues[i].dwValue * dwVolume / pDialogData-> maxVolume;
241 }
242 }
243
244 mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
245 mxcd.dwControlID = pDialogData->volumeControlID;
246 mxcd.cChannels = pDialogData->volumeChannels;
247 mxcd.cMultipleItems = 0;
249 mxcd.paDetails = pDialogData->volumeCurrentValues;
250
251 mixerSetControlDetails((HMIXEROBJ)pDialogData->hMixer,
252 &mxcd,
254 break;
255 }
256}
#define PlaySound
Definition: mmsystem.h:2842
#define SND_ALIAS_SYSTEMDEFAULT
Definition: mmsystem.h:175
#define SND_ALIAS_ID
Definition: mmsystem.h:161
#define SND_ASYNC
Definition: mmsystem.h:154
#define for
Definition: utility.h:88
#define DWORD
Definition: nt_native.h:44
#define TB_ENDTRACK
Definition: commctrl.h:2081
#define TB_THUMBPOSITION
Definition: commctrl.h:2077
#define TBM_GETPOS
Definition: commctrl.h:2031
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by TrayDlgProc().

◆ TrayDlgProc()

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

Definition at line 262 of file tray.c.

267{
268 PDIALOG_DATA pDialogData;
269
270 pDialogData = (PDIALOG_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
271
272 switch (uMsg)
273 {
274 case WM_INITDIALOG:
275 OnTrayInitDialog(hwndDlg, wParam, lParam);
276
278 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pDialogData);
279
280 if (pDialogData)
281 OnTrayInitMixer(pDialogData, hwndDlg);
282 break;
283
284 case WM_COMMAND:
285 if (pDialogData)
286 OnCommand(pDialogData, hwndDlg, wParam, lParam);
287 break;
288
289 case WM_VSCROLL:
290 if (pDialogData)
291 OnVScroll(pDialogData, hwndDlg, wParam, lParam);
292 break;
293
294 case WM_DESTROY:
295 if (pDialogData)
296 {
297 if (pDialogData->volumeInitValues)
298 HeapFree(GetProcessHeap(), 0, pDialogData->volumeInitValues);
299
300 if (pDialogData->volumeCurrentValues)
301 HeapFree(GetProcessHeap(), 0, pDialogData->volumeCurrentValues);
302
303 if (pDialogData->hMixer)
304 mixerClose(pDialogData->hMixer);
305
306 HeapFree(GetProcessHeap(), 0, pDialogData);
307 pDialogData = NULL;
309 }
310 break;
311
312 case WM_ACTIVATE:
313 if (LOWORD(wParam) == WA_INACTIVE)
314 EndDialog(hwndDlg, IDOK);
315 break;
316 }
317
318 return 0;
319}
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static VOID OnCommand(PDIALOG_DATA pDialogData, HWND hwndDlg, WPARAM wParam, LPARAM lParam)
Definition: tray.c:173
static VOID OnTrayInitMixer(PDIALOG_DATA pDialogData, HWND hwndDlg)
Definition: tray.c:64
struct _DIALOG_DATA DIALOG_DATA
static VOID OnTrayInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: tray.c:29
struct _DIALOG_DATA * PDIALOG_DATA
static VOID OnVScroll(PDIALOG_DATA pDialogData, HWND hwndDlg, WPARAM wParam, LPARAM lParam)
Definition: tray.c:203
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
UINT WINAPI mixerClose(HMIXER hMix)
Definition: winmm.c:386
#define DWLP_USER
Definition: winuser.h:872
#define WM_VSCROLL
Definition: winuser.h:1744
#define WM_COMMAND
Definition: winuser.h:1740
#define WA_INACTIVE
Definition: winuser.h:2622
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
#define WM_ACTIVATE
Definition: winuser.h:1612
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by _tWinMain().