1 #ifndef __SNDVOL32_H
2 #define __SNDVOL32_H
3 
4 #include <stdarg.h>
5 
6 #include <windef.h>
7 #include <winbase.h>
8 #include <wingdi.h>
9 #include <winuser.h>
10 #include <mmsystem.h>
11 #include <commctrl.h>
12 #include <tchar.h>
13 #include <strsafe.h>
14 #include <assert.h>
15 
16 #include "resources.h"
17 
18 #define VOLUME_MIN           0
19 #define VOLUME_MAX         500
20 #define VOLUME_TICKS         5
21 #define VOLUME_PAGE_SIZE   100
22 #define BALANCE_LEFT         0
23 #define BALANCE_CENTER      32
24 #define BALANCE_RIGHT       64
25 #define BALANCE_STEPS       64
26 #define BALANCE_TICKS        1
27 #define BALANCE_PAGE_SIZE   12
28 
29 #define PLAY_MIXER           0
30 #define RECORD_MIXER         1
31 
32 #define ADVANCED_BUTTON_HEIGHT 16
33 
34 typedef enum _WINDOW_MODE
35 {
36     NORMAL_MODE,
37     SMALL_MODE,
38     TRAY_MODE
39 } WINDOW_MODE, *PWINDOW_MODE;
40 
41 typedef struct _MIXER_WINDOW
42 {
43   HWND hWnd;
44   HWND hStatusBar;
45   struct _SND_MIXER *Mixer;
46   UINT SelectedLine;
47   UINT WindowCount;
48   HWND *Window;
49     UINT DialogCount;
50 
51     WINDOW_MODE Mode;
52     UINT MixerId;
53     BOOL bHasExtendedControls;
54     BOOL bShowExtendedControls;
55     RECT rect;
56     HFONT hFont;
57     SIZE baseUnit;
58     INT WndPosX;
59     INT WndPosY;
60 } MIXER_WINDOW, *PMIXER_WINDOW;
61 
62 extern HINSTANCE hAppInstance;
63 extern ATOM MainWindowClass;
64 extern HWND hMainWnd;
65 extern HANDLE hAppHeap;
66 
67 #define SZ_APP_CLASS TEXT("Volume Control")
68 #define _countof(array) (sizeof(array) / sizeof(array[0]))
69 
70 ULONG DbgPrint(PCH , ...);
71 #define DPRINT DbgPrint("SNDVOL32: %s:%i: ", __FILE__, __LINE__); DbgPrint
72 
73 
74 /*
75  * MIXER
76  */
77 
78 typedef struct _SND_MIXER_CONNECTION
79 {
80   struct _SND_MIXER_CONNECTION *Next;
81   MIXERLINE Info;
82   LPMIXERCONTROL Controls;
83   UINT DisplayControls;
84 } SND_MIXER_CONNECTION, *PSND_MIXER_CONNECTION;
85 
86 
87 typedef struct _SND_MIXER_DESTINATION
88 {
89   struct _SND_MIXER_DESTINATION *Next;
90   MIXERLINE Info;
91   LPMIXERCONTROL Controls;
92   UINT DisplayControls;
93   PSND_MIXER_CONNECTION Connections;
94 } SND_MIXER_DESTINATION, *PSND_MIXER_DESTINATION;
95 
96 typedef struct _SND_MIXER
97 {
98   UINT MixersCount;
99   HWND hWndNotification;
100   UINT MixerId;
101   HMIXER hmx;
102   MIXERCAPS Caps;
103   PSND_MIXER_DESTINATION Lines;
104 } SND_MIXER, *PSND_MIXER;
105 
106 typedef struct _PREFERENCES_CONTEXT
107 {
108     PMIXER_WINDOW MixerWindow;
109     PSND_MIXER Mixer;
110     HWND hwndDlg;
111 
112     UINT Selected;
113     DWORD SelectedLine;
114     DWORD PlaybackID;
115     DWORD RecordingID;
116     UINT OtherLines;
117     TCHAR DeviceName[128];
118 
119     DWORD tmp;
120 } PREFERENCES_CONTEXT, *PPREFERENCES_CONTEXT;
121 
122 typedef struct _SET_VOLUME_CONTEXT
123 {
124     WCHAR LineName[MIXER_LONG_NAME_CHARS];
125     UINT SliderPos;
126     BOOL bVertical;
127     BOOL bSwitch;
128 } SET_VOLUME_CONTEXT, *PSET_VOLUME_CONTEXT;
129 
130 typedef struct _ADVANCED_CONTEXT
131 {
132     WCHAR LineName[MIXER_LONG_NAME_CHARS];
133     PMIXER_WINDOW MixerWindow;
134     PSND_MIXER Mixer;
135     LPMIXERLINE Line;
136 } ADVANCED_CONTEXT, *PADVANCED_CONTEXT;
137 
138 
139 /* NOTE: do NOT modify SNDVOL_REG_LINESTATE for binary compatibility with XP! */
140 typedef struct _SNDVOL_REG_LINESTATE
141 {
142     DWORD Flags;
143     WCHAR LineName[MIXER_LONG_NAME_CHARS];
144 } SNDVOL_REG_LINESTATE, *PSNDVOL_REG_LINESTATE;
145 
146 
147 typedef BOOL (CALLBACK *PFNSNDMIXENUMLINES)(PSND_MIXER Mixer, LPMIXERLINE Line, UINT DisplayControls, PVOID Context);
148 typedef BOOL (CALLBACK *PFNSNDMIXENUMCONNECTIONS)(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Context);
149 typedef BOOL (CALLBACK *PFNSNDMIXENUMPRODUCTS)(PSND_MIXER Mixer, UINT Id, LPCTSTR ProductName, PVOID Context);
150 
151 PSND_MIXER SndMixerCreate(HWND hWndNotification, UINT MixerId);
152 VOID SndMixerDestroy(PSND_MIXER Mixer);
153 VOID SndMixerClose(PSND_MIXER Mixer);
154 BOOL SndMixerSelect(PSND_MIXER Mixer, UINT MixerId);
155 UINT SndMixerGetSelection(PSND_MIXER Mixer);
156 INT SndMixerSetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cChannels, DWORD cbDetails, LPVOID paDetails);
157 INT SndMixerGetVolumeControlDetails(PSND_MIXER Mixer, DWORD dwControlID, DWORD cChannels, DWORD cbDetails, LPVOID paDetails);
158 INT SndMixerGetProductName(PSND_MIXER Mixer, LPTSTR lpBuffer, UINT uSize);
159 INT SndMixerGetLineName(PSND_MIXER Mixer, DWORD LineID, LPTSTR lpBuffer, UINT uSize, BOOL LongName);
160 BOOL SndMixerEnumProducts(PSND_MIXER Mixer, PFNSNDMIXENUMPRODUCTS EnumProc, PVOID Context);
161 INT SndMixerGetDestinationCount(PSND_MIXER Mixer);
162 BOOL SndMixerEnumLines(PSND_MIXER Mixer, PFNSNDMIXENUMLINES EnumProc, PVOID Context);
163 BOOL SndMixerEnumConnections(PSND_MIXER Mixer, DWORD LineID, PFNSNDMIXENUMCONNECTIONS EnumProc, PVOID Context);
164 BOOL SndMixerIsDisplayControl(PSND_MIXER Mixer, LPMIXERCONTROL Control);
165 BOOL SndMixerQueryControls(PSND_MIXER Mixer, PUINT DisplayControls, LPMIXERLINE LineInfo, LPMIXERCONTROL *Controls);
166 LPMIXERLINE SndMixerGetLineByName(PSND_MIXER Mixer, DWORD LineID, LPWSTR LineName);
167 
168 /* advanced.c */
169 
170 INT_PTR
171 CALLBACK
172 AdvancedDlgProc(
173     HWND hwndDlg,
174     UINT uMsg,
175     WPARAM wParam,
176     LPARAM lParam);
177 
178 
179 /*
180  * dialog.c
181  */
182 VOID LoadDialogCtrls(PPREFERENCES_CONTEXT PrefContext);
183 VOID UpdateDialogLineSliderControl(PPREFERENCES_CONTEXT PrefContext, LPMIXERLINE Line, DWORD DialogID, DWORD Position);
184 VOID UpdateDialogLineSwitchControl(PPREFERENCES_CONTEXT PrefContext, LPMIXERLINE Line, LONG fValue);
185 
186 /*
187  * MISC
188  */
189 
190 extern HKEY hAppSettingsKey;
191 
192 BOOL
193 InitAppConfig(VOID);
194 
195 VOID
196 CloseAppConfig(VOID);
197 
198 BOOL
199 LoadXYCoordWnd(IN PPREFERENCES_CONTEXT PrefContext);
200 
201 BOOL
202 SaveXYCoordWnd(IN HWND hWnd,
203                IN PPREFERENCES_CONTEXT PrefContext);
204 
205 INT
206 AllocAndLoadString(OUT LPWSTR *lpTarget,
207                    IN HINSTANCE hInst,
208                    IN UINT uID);
209 
210 DWORD
211 LoadAndFormatString(IN HINSTANCE hInstance,
212                     IN UINT uID,
213                     OUT LPWSTR *lpTarget,
214                     ...);
215 
216 BOOL
217 ReadLineConfig(IN LPTSTR szDeviceName,
218                IN LPTSTR szLineName,
219                IN LPTSTR szControlName,
220                OUT DWORD *Flags);
221 
222 BOOL
223 WriteLineConfig(IN LPTSTR szDeviceName,
224                 IN LPTSTR szLineName,
225                 IN PSNDVOL_REG_LINESTATE LineState,
226                 IN DWORD cbSize);
227 
228 DWORD
229 GetStyleValue(VOID);
230 
231 /* tray.c */
232 
233 INT_PTR
234 CALLBACK
235 TrayDlgProc(
236     HWND hwndDlg,
237     UINT uMsg,
238     WPARAM wParam,
239     LPARAM lParam);
240 
241 #endif /* __SNDVOL32_H */
242