2 * ReactOS Sound Volume Control
3 * Copyright (C) 2004-2005 Thomas Weidenmueller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS Sound Volume Control
23 * FILE: subsys/system/sndvol32/sndvol32.c
24 * PROGRAMMERS: Thomas Weidenmueller <w3seek@reactos.com>
28 HINSTANCE hAppInstance
;
33 PREFERENCES_CONTEXT Preferences
;
35 #define GetDialogData(hwndDlg, type) \
36 ( P##type )GetWindowLongPtr((hwndDlg), DWLP_USER)
37 #define GetWindowData(hwnd, type) \
38 ( P##type )GetWindowLongPtr((hwnd), GWL_USERDATA)
40 /******************************************************************************/
44 typedef struct _PREFERENCES_FILL_DEVICES
46 PPREFERENCES_CONTEXT PrefContext
;
49 } PREFERENCES_FILL_DEVICES
, *PPREFERENCES_FILL_DEVICES
;
52 FillDeviceComboBox(PSND_MIXER Mixer
,
58 PPREFERENCES_FILL_DEVICES FillContext
= (PPREFERENCES_FILL_DEVICES
)Context
;
60 UNREFERENCED_PARAMETER(Mixer
);
62 lres
= SendMessage(FillContext
->hComboBox
,
68 /* save the index so we don't screw stuff when the combobox is sorted... */
69 SendMessage(FillContext
->hComboBox
,
74 if (Id
== FillContext
->Selected
)
76 SendMessage(FillContext
->hComboBox
,
87 PrefDlgAddLine(PSND_MIXER Mixer
,
92 PPREFERENCES_CONTEXT PrefContext
= (PPREFERENCES_CONTEXT
)Context
;
94 UNREFERENCED_PARAMETER(Mixer
);
95 UNREFERENCED_PARAMETER(DisplayControls
);
97 switch (Line
->dwComponentType
)
99 case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
:
100 if (PrefContext
->PlaybackID
== (DWORD
)-1)
102 PrefContext
->PlaybackID
= Line
->dwLineID
;
104 if (PrefContext
->SelectedLine
== (DWORD
)-1)
106 PrefContext
->SelectedLine
= Line
->dwLineID
;
110 goto AddToOthersLines
;
114 case MIXERLINE_COMPONENTTYPE_DST_WAVEIN
:
115 if (PrefContext
->RecordingID
== (DWORD
)-1)
117 PrefContext
->RecordingID
= Line
->dwLineID
;
119 if (PrefContext
->SelectedLine
== (DWORD
)-1)
121 PrefContext
->SelectedLine
= Line
->dwLineID
;
125 goto AddToOthersLines
;
134 if (PrefContext
->SelectedLine
== (DWORD
)-1)
136 PrefContext
->SelectedLine
= Line
->dwLineID
;
140 hwndCbOthers
= GetDlgItem(PrefContext
->hwndDlg
,
143 lres
= SendMessage(hwndCbOthers
,
146 (LPARAM
)Line
->szName
);
149 SendMessage(hwndCbOthers
,
154 PrefContext
->OtherLines
++;
164 PrefDlgAddConnection(PSND_MIXER Mixer
,
169 PPREFERENCES_CONTEXT PrefContext
= (PPREFERENCES_CONTEXT
)Context
;
174 UNREFERENCED_PARAMETER(Mixer
);
175 UNREFERENCED_PARAMETER(LineID
);
177 if (Line
->cControls
!= 0)
179 hwndControls
= GetDlgItem(PrefContext
->hwndDlg
,
182 lvi
.mask
= LVIF_TEXT
| LVIF_PARAM
;
183 lvi
.iItem
= PrefContext
->tmp
++;
185 lvi
.pszText
= Line
->szName
;
186 lvi
.lParam
= (LPARAM
)Line
->dwSource
;
188 i
= SendMessage(hwndControls
,
194 TCHAR LineName
[MIXER_LONG_NAME_CHARS
];
196 BOOL SelLine
= FALSE
;
198 if (SndMixerGetLineName(PrefContext
->Mixer
,
199 PrefContext
->SelectedLine
,
201 MIXER_LONG_NAME_CHARS
,
204 LineName
[0] = TEXT('\0');
207 if (ReadLineConfig(PrefContext
->DeviceName
,
218 ListView_SetCheckState(hwndControls
,
228 UpdatePrefDlgControls(PPREFERENCES_CONTEXT Context
,
231 INT OldID
, MixerID
= 0;
234 /* select the mixer */
235 DeviceCbIndex
= SendDlgItemMessage(Context
->hwndDlg
,
240 if (DeviceCbIndex
!= CB_ERR
)
242 MixerID
= SendDlgItemMessage(Context
->hwndDlg
,
247 if (MixerID
== CB_ERR
)
253 OldID
= Context
->Selected
;
254 if (MixerID
!= OldID
&&
255 SndMixerSelect(Context
->Mixer
,
258 Context
->Selected
= SndMixerGetSelection(Context
->Mixer
);
260 /* update the controls */
261 Context
->PlaybackID
= (DWORD
)-1;
262 Context
->RecordingID
= (DWORD
)-1;
263 Context
->OtherLines
= 0;
264 Context
->SelectedLine
= (DWORD
)-1;
266 SndMixerGetProductName(Context
->Mixer
,
268 sizeof(Context
->DeviceName
) / sizeof(Context
->DeviceName
[0]));
270 if (SndMixerEnumLines(Context
->Mixer
,
276 /* enable/disable controls and make default selection */
277 EnableWindow(GetDlgItem(Context
->hwndDlg
,
279 Context
->PlaybackID
!= (DWORD
)-1);
280 CheckDlgButton(Context
->hwndDlg
,
282 (Context
->PlaybackID
!= (DWORD
)-1 && SelBox
++ == 0) ?
283 BST_CHECKED
: BST_UNCHECKED
);
285 EnableWindow(GetDlgItem(Context
->hwndDlg
,
287 Context
->RecordingID
!= (DWORD
)-1);
288 CheckDlgButton(Context
->hwndDlg
,
290 (Context
->RecordingID
!= (DWORD
)-1 && SelBox
++ == 0) ?
291 BST_CHECKED
: BST_UNCHECKED
);
293 if (Context
->OtherLines
!= 0)
295 /* select the first item in the other lines combo box by default */
296 SendDlgItemMessage(Context
->hwndDlg
,
302 EnableWindow(GetDlgItem(Context
->hwndDlg
,
305 EnableWindow(GetDlgItem(Context
->hwndDlg
,
307 Context
->OtherLines
!= 0);
308 CheckDlgButton(Context
->hwndDlg
,
310 (Context
->OtherLines
!= 0 && SelBox
++ == 0) ?
311 BST_CHECKED
: BST_UNCHECKED
);
313 /* disable the OK button if the device doesn't have any lines */
314 EnableWindow(GetDlgItem(Context
->hwndDlg
,
316 Context
->PlaybackID
!= (DWORD
)-1 ||
317 Context
->RecordingID
!= (DWORD
)-1 ||
318 Context
->OtherLines
!= 0);
320 LineID
= Context
->SelectedLine
;
324 /* update the line sources list */
325 if ((MixerID
!= OldID
&& Context
->SelectedLine
!= (DWORD
)-1) ||
326 (Context
->SelectedLine
!= LineID
&& LineID
!= (DWORD
)-1))
328 Context
->SelectedLine
= LineID
;
330 (void)ListView_DeleteAllItems(GetDlgItem(Context
->hwndDlg
,
334 SndMixerEnumConnections(Context
->Mixer
,
336 PrefDlgAddConnection
,
343 WriteLineSettings(PPREFERENCES_CONTEXT Context
, HWND hwndDlg
)
347 WCHAR LineName
[MIXER_LONG_NAME_CHARS
];
348 WCHAR DestinationName
[MIXER_LONG_NAME_CHARS
];
350 PSNDVOL_REG_LINESTATE LineStates
;
353 hwndControls
= GetDlgItem(hwndDlg
, IDC_CONTROLS
);
355 /* get list item count */
356 Count
= ListView_GetItemCount(hwndControls
);
361 if (SndMixerGetLineName(Context
->Mixer
, Context
->SelectedLine
, DestinationName
, MIXER_LONG_NAME_CHARS
, TRUE
) == -1)
363 /* failed to get destination line name */
367 /* allocate line states array */
368 LineStates
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SNDVOL_REG_LINESTATE
) * Count
);
369 if (LineStates
== NULL
)
371 /* failed to allocate line states array */
376 for(Index
= 0; Index
< Count
; Index
++)
382 ListView_GetItemText(hwndControls
, Index
, 0, LineName
, MIXER_LONG_NAME_CHARS
);
384 /* make sure it is null terminated */
385 LineName
[MIXER_LONG_NAME_CHARS
-1] = L
'\0';
387 /* get check state */
388 Flags
= (ListView_GetCheckState(hwndControls
, Index
) == 0 ? 0x4 : 0);
391 wcscpy(LineStates
[Index
].LineName
, LineName
);
394 LineStates
[Index
].Flags
= Flags
;
397 /* now write the line config */
398 WriteLineConfig(Context
->DeviceName
, DestinationName
, LineStates
, sizeof(SNDVOL_REG_LINESTATE
) * Count
);
400 /* free line states */
401 HeapFree(GetProcessHeap(), 0, LineStates
);
404 static INT_PTR CALLBACK
405 DlgPreferencesProc(HWND hwndDlg
,
410 PPREFERENCES_CONTEXT Context
;
416 Context
= GetDialogData(hwndDlg
,
417 PREFERENCES_CONTEXT
);
418 switch (LOWORD(wParam
))
420 case IDC_MIXERDEVICE
:
422 if (HIWORD(wParam
) == CBN_SELCHANGE
)
424 UpdatePrefDlgControls(Context
,
432 if (HIWORD(wParam
) == CBN_SELCHANGE
)
437 Index
= SendDlgItemMessage(hwndDlg
,
444 LineID
= SendDlgItemMessage(hwndDlg
,
449 if (LineID
!= CB_ERR
)
451 UpdatePrefDlgControls(Context
,
461 UpdatePrefDlgControls(Context
,
462 Context
->PlaybackID
);
463 EnableWindow(GetDlgItem(hwndDlg
,
471 UpdatePrefDlgControls(Context
,
472 Context
->RecordingID
);
473 EnableWindow(GetDlgItem(hwndDlg
,
484 EnableWindow(GetDlgItem(hwndDlg
,
488 LineCbIndex
= SendDlgItemMessage(hwndDlg
,
493 if (LineCbIndex
!= CB_ERR
)
495 LineID
= SendDlgItemMessage(hwndDlg
,
500 if (LineID
!= CB_ERR
)
502 UpdatePrefDlgControls(Context
,
511 /* write line settings */
512 WriteLineSettings(Context
, hwndDlg
);
528 PREFERENCES_FILL_DEVICES FillDevContext
;
533 SetWindowLongPtr(hwndDlg
,
536 Context
= (PPREFERENCES_CONTEXT
)((LONG_PTR
)lParam
);
537 Context
->hwndDlg
= hwndDlg
;
538 Context
->Mixer
= SndMixerCreate(hwndDlg
);
539 Context
->Selected
= (UINT
)-1;
541 FillDevContext
.PrefContext
= Context
;
542 FillDevContext
.hComboBox
= GetDlgItem(hwndDlg
,
544 FillDevContext
.Selected
= SndMixerGetSelection(Context
->Mixer
);
545 SndMixerEnumProducts(Context
->Mixer
,
549 /* initialize the list view control */
550 hwndControls
= GetDlgItem(hwndDlg
,
552 (void)ListView_SetExtendedListViewStyle(hwndControls
,
555 GetClientRect(hwndControls
,
557 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
558 lvc
.pszText
= TEXT("");
559 lvc
.cx
= rcClient
.right
;
560 SendMessage(hwndControls
,
565 /* update all controls */
566 UpdatePrefDlgControls(Context
,
567 (DWORD
)Context
->SelectedLine
);
578 case WM_SYSCOLORCHANGE
:
582 /* Forward WM_SYSCOLORCHANGE */
583 hwndControls
= GetDlgItem(hwndDlg
, IDC_CONTROLS
);
584 SendMessage(hwndControls
, WM_SYSCOLORCHANGE
, 0, 0);
593 /******************************************************************************/
596 DeleteMixerWindowControls(PMIXER_WINDOW MixerWindow
)
600 for(Index
= 0; Index
< MixerWindow
->WindowCount
; Index
++)
602 /* destroys the window */
603 DestroyWindow(MixerWindow
->Window
[Index
]);
607 HeapFree(GetProcessHeap(), 0, MixerWindow
->Window
);
610 MixerWindow
->Window
= NULL
;
611 MixerWindow
->WindowCount
= 0;
615 RebuildMixerWindowControls(PPREFERENCES_CONTEXT PrefContext
)
617 /* delete existing mixer controls */
618 DeleteMixerWindowControls(PrefContext
->MixerWindow
);
620 /* load new mixer controls */
621 LoadDialogCtrls(PrefContext
);
629 SetVolumeCallback(PSND_MIXER Mixer
, DWORD LineID
, LPMIXERLINE Line
, PVOID Ctx
)
631 UINT ControlCount
= 0, Index
;
632 LPMIXERCONTROL Control
= NULL
;
633 MIXERCONTROLDETAILS_UNSIGNED uDetails
;
634 MIXERCONTROLDETAILS_BOOLEAN bDetails
;
635 PSET_VOLUME_CONTEXT Context
= (PSET_VOLUME_CONTEXT
)Ctx
;
637 /* check if the line name is equal */
638 if (wcsicmp(Line
->szName
, Context
->LineName
))
645 if (SndMixerQueryControls(Mixer
, &ControlCount
, Line
, &Control
) == FALSE
)
647 /* failed to query for controls */
651 /* now go through all controls and compare control ids */
652 for(Index
= 0; Index
< ControlCount
; Index
++)
654 if (Context
->bVertical
)
656 if ((Control
[Index
].dwControlType
& MIXERCONTROL_CT_CLASS_MASK
) == MIXERCONTROL_CT_CLASS_FADER
)
658 /* FIXME: give me granularity */
659 DWORD Step
= 0x10000 / 5;
662 uDetails
.dwValue
= 0x10000 - Step
* Context
->SliderPos
;
665 SndMixerSetVolumeControlDetails(Preferences
.MixerWindow
->Mixer
, Control
[Index
].dwControlID
, sizeof(MIXERCONTROLDETAILS_UNSIGNED
), (LPVOID
)&uDetails
);
671 else if (Context
->bSwitch
)
673 if ((Control
[Index
].dwControlType
& MIXERCONTROL_CT_CLASS_MASK
) == MIXERCONTROL_CT_CLASS_SWITCH
)
676 bDetails
.fValue
= Context
->SliderPos
;
679 SndMixerSetVolumeControlDetails(Preferences
.MixerWindow
->Mixer
, Control
[Index
].dwControlID
, sizeof(MIXERCONTROLDETAILS_BOOLEAN
), (LPVOID
)&bDetails
);
687 /* FIXME: implement left - right channel switch support */
693 HeapFree(GetProcessHeap(), 0, Control
);
703 MixerControlChangeCallback(PSND_MIXER Mixer
, DWORD LineID
, LPMIXERLINE Line
, PVOID Context
)
705 UINT ControlCount
= 0, Index
;
706 LPMIXERCONTROL Control
= NULL
;
708 /* check if the line has controls */
709 if (Line
->cControls
== 0)
716 if (SndMixerQueryControls(Mixer
, &ControlCount
, Line
, &Control
) == FALSE
)
718 /* failed to query for controls */
722 /* now go through all controls and compare control ids */
723 for(Index
= 0; Index
< ControlCount
; Index
++)
725 if (Control
[Index
].dwControlID
== PtrToUlong(Context
))
727 if ((Control
[Index
].dwControlType
& MIXERCONTROL_CT_CLASS_MASK
) == MIXERCONTROL_CT_CLASS_SWITCH
)
729 MIXERCONTROLDETAILS_BOOLEAN Details
;
731 /* get volume control details */
732 if (SndMixerGetVolumeControlDetails(Preferences
.MixerWindow
->Mixer
, Control
[Index
].dwControlID
, sizeof(MIXERCONTROLDETAILS_BOOLEAN
), (LPVOID
)&Details
) != -1)
734 /* update dialog control */
735 UpdateDialogLineSwitchControl(&Preferences
, Line
, Details
.fValue
);
738 else if ((Control
[Index
].dwControlType
& MIXERCONTROL_CT_CLASS_MASK
) == MIXERCONTROL_CT_CLASS_FADER
)
740 MIXERCONTROLDETAILS_UNSIGNED Details
;
742 /* get volume control details */
743 if (SndMixerGetVolumeControlDetails(Preferences
.MixerWindow
->Mixer
, Control
[Index
].dwControlID
, sizeof(MIXERCONTROLDETAILS_UNSIGNED
), (LPVOID
)&Details
) != -1)
745 /* update dialog control */
747 DWORD Step
= 0x10000 / 5;
749 /* FIXME: give me granularity */
750 Position
= 5 - (Details
.dwValue
/ Step
);
752 /* update volume control slider */
753 UpdateDialogLineSliderControl(&Preferences
, Line
, Control
[Index
].dwControlID
, IDC_LINE_SLIDER_VERT
, Position
);
761 HeapFree(GetProcessHeap(), 0, Control
);
769 static LRESULT CALLBACK
770 MainWindowProc(HWND hwnd
,
775 PMIXER_WINDOW MixerWindow
;
776 DWORD CtrlID
, LineOffset
;
778 SET_VOLUME_CONTEXT Context
;
784 MixerWindow
= GetWindowData(hwnd
,
787 switch (LOWORD(wParam
))
791 PREFERENCES_CONTEXT Pref
;
793 Pref
.MixerWindow
= MixerWindow
;
795 Pref
.SelectedLine
= Preferences
.SelectedLine
;
797 if (DialogBoxParam(hAppInstance
,
798 MAKEINTRESOURCE(IDD_PREFERENCES
),
801 (LPARAM
)&Pref
) == IDOK
)
804 TCHAR szProduct
[MAXPNAMELEN
];
806 /* get mixer product name */
807 if (SndMixerGetProductName(MixerWindow
->Mixer
,
809 sizeof(szProduct
) / sizeof(szProduct
[0])) == -1)
811 /* failed to get name */
812 szProduct
[0] = L
'\0';
817 wcscpy(Preferences
.DeviceName
, szProduct
);
820 /* destroy old status bar */
821 DestroyWindow(MixerWindow
->hStatusBar
);
824 Preferences
.SelectedLine
= Pref
.SelectedLine
;
826 /* destroy old mixer */
827 SndMixerDestroy(Preferences
.MixerWindow
->Mixer
);
829 /* use new selected mixer */
830 Preferences
.MixerWindow
->Mixer
= Pref
.Mixer
;
832 /* rebuild dialog controls */
833 RebuildMixerWindowControls(&Preferences
);
835 /* create status window */
836 MixerWindow
->hStatusBar
= CreateStatusWindow(WS_VISIBLE
| WS_CHILD
| WS_CLIPSIBLINGS
,
842 if (MixerWindow
->hStatusBar
)
844 SendMessage(MixerWindow
->hStatusBar
,
861 HICON hAppIcon
= (HICON
)GetClassLongPtrW(hwnd
,
873 CtrlID
= LOWORD(wParam
);
875 /* check if the message is from the line switch */
876 if (HIWORD(wParam
) == BN_CLICKED
&& (CtrlID
% IDC_LINE_SWITCH
== 0))
878 /* compute line offset */
879 LineOffset
= CtrlID
/ IDC_LINE_SWITCH
;
881 /* compute window id of line name static control */
882 CtrlID
= LineOffset
* IDC_LINE_NAME
;
885 if (GetDlgItemTextW(hwnd
, CtrlID
, Context
.LineName
, MIXER_LONG_NAME_CHARS
) != 0)
888 Context
.SliderPos
= SendMessage((HWND
)lParam
, BM_GETCHECK
, 0, 0);
889 Context
.bVertical
= FALSE
;
890 Context
.bSwitch
= TRUE
;
893 SndMixerEnumConnections(Preferences
.MixerWindow
->Mixer
, Preferences
.SelectedLine
, SetVolumeCallback
, (LPVOID
)&Context
);
902 case MM_MIXM_LINE_CHANGE
:
904 DPRINT("MM_MIXM_LINE_CHANGE\n");
908 case MM_MIXM_CONTROL_CHANGE
:
910 DPRINT("MM_MIXM_CONTROL_CHANGE\n");
912 /* get mixer window */
913 MixerWindow
= GetWindowData(hwnd
,
918 assert(MixerWindow
->Mixer
->hmx
== (HMIXER
)wParam
);
920 SndMixerEnumConnections(MixerWindow
->Mixer
, Preferences
.SelectedLine
, MixerControlChangeCallback
, (PVOID
)lParam
);
926 if (LOWORD(wParam
) == TB_THUMBTRACK
)
928 /* get dialog item ctrl */
929 CtrlID
= GetDlgCtrlID((HWND
)lParam
);
932 LineOffset
= CtrlID
/ IDC_LINE_SLIDER_VERT
;
934 /* compute window id of line name static control */
935 CtrlID
= LineOffset
* IDC_LINE_NAME
;
938 if (GetDlgItemTextW(hwnd
, CtrlID
, Context
.LineName
, MIXER_LONG_NAME_CHARS
) != 0)
941 Context
.SliderPos
= HIWORD(wParam
);
942 Context
.bVertical
= TRUE
;
943 Context
.bSwitch
= FALSE
;
946 SndMixerEnumConnections(Preferences
.MixerWindow
->Mixer
, Preferences
.SelectedLine
, SetVolumeCallback
, (LPVOID
)&Context
);
956 MixerWindow
= ((LPCREATESTRUCT
)lParam
)->lpCreateParams
;
957 SetWindowLongPtr(hwnd
,
959 (LONG_PTR
)MixerWindow
);
960 MixerWindow
->hWnd
= hwnd
;
961 MixerWindow
->Mixer
= SndMixerCreate(MixerWindow
->hWnd
);
962 if (MixerWindow
->Mixer
!= NULL
)
964 TCHAR szProduct
[MAXPNAMELEN
];
966 /* get mixer product name */
967 if (SndMixerGetProductName(MixerWindow
->Mixer
,
969 sizeof(szProduct
) / sizeof(szProduct
[0])) == -1)
971 /* failed to get name */
972 szProduct
[0] = L
'\0';
976 /* initialize perferences */
977 ZeroMemory(&Preferences
, sizeof(Preferences
));
980 Preferences
.Mixer
= MixerWindow
->Mixer
;
982 /* store mixer window */
983 Preferences
.MixerWindow
= MixerWindow
;
985 /* first destination line id */
986 Preferences
.SelectedLine
= 0xFFFF0000;
989 wcscpy(Preferences
.DeviceName
, szProduct
);
991 if (!RebuildMixerWindowControls(&Preferences
))
993 DPRINT("Rebuilding mixer window controls failed!\n");
994 SndMixerDestroy(MixerWindow
->Mixer
);
995 MixerWindow
->Mixer
= NULL
;
999 /* create status window */
1000 MixerWindow
->hStatusBar
= CreateStatusWindow(WS_VISIBLE
| WS_CHILD
| WS_CLIPSIBLINGS
,
1004 if (MixerWindow
->hStatusBar
)
1006 SendMessage(MixerWindow
->hStatusBar
,
1017 MixerWindow
= GetWindowData(hwnd
,
1019 if (MixerWindow
->Mixer
!= NULL
)
1021 SndMixerDestroy(MixerWindow
->Mixer
);
1034 Result
= DefWindowProc(hwnd
,
1046 RegisterApplicationClasses(VOID
)
1050 wc
.cbSize
= sizeof(WNDCLASSEX
);
1051 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
1052 wc
.lpfnWndProc
= MainWindowProc
;
1054 wc
.cbWndExtra
= sizeof(PMIXER_WINDOW
);
1055 wc
.hInstance
= hAppInstance
;
1056 wc
.hIcon
= LoadIcon(hAppInstance
,
1057 MAKEINTRESOURCE(IDI_MAINAPP
));
1058 wc
.hCursor
= LoadCursor(NULL
,
1060 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
1061 wc
.lpszMenuName
= NULL
;
1062 wc
.lpszClassName
= SZ_APP_CLASS
;
1064 MainWindowClass
= RegisterClassEx(&wc
);
1066 return MainWindowClass
!= 0;
1070 UnregisterApplicationClasses(VOID
)
1072 UnregisterClass(SZ_APP_CLASS
,
1077 CreateApplicationWindow(VOID
)
1081 PMIXER_WINDOW MixerWindow
= HeapAlloc(hAppHeap
,
1083 sizeof(MIXER_WINDOW
));
1084 if (MixerWindow
== NULL
)
1089 if (mixerGetNumDevs() > 0)
1091 hWnd
= CreateWindowEx(WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
,
1094 WS_DLGFRAME
| WS_CAPTION
| WS_MINIMIZEBOX
| WS_SYSMENU
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
| WS_VISIBLE
,
1097 LoadMenu(hAppInstance
,
1098 MAKEINTRESOURCE(IDM_MAINMENU
)),
1104 LPTSTR lpErrMessage
;
1107 * no mixer devices are available!
1111 if (AllocAndLoadString(&lpErrMessage
,
1113 IDS_NOMIXERDEVICES
))
1118 MB_ICONINFORMATION
);
1119 LocalFree(lpErrMessage
);
1134 _tWinMain(HINSTANCE hInstance
,
1135 HINSTANCE hPrevInstance
,
1141 INITCOMMONCONTROLSEX Controls
;
1143 UNREFERENCED_PARAMETER(hPrevInstance
);
1144 UNREFERENCED_PARAMETER(lpszCmdLine
);
1145 UNREFERENCED_PARAMETER(nCmdShow
);
1147 hAppInstance
= hInstance
;
1148 hAppHeap
= GetProcessHeap();
1150 if (InitAppConfig())
1152 /* load the application title */
1153 if (!AllocAndLoadString(&lpAppTitle
,
1160 Controls
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1161 Controls
.dwICC
= ICC_BAR_CLASSES
| ICC_STANDARD_CLASSES
;
1163 InitCommonControlsEx(&Controls
);
1165 if (RegisterApplicationClasses())
1167 hMainWnd
= CreateApplicationWindow();
1168 if (hMainWnd
!= NULL
)
1171 while ((bRet
=GetMessage(&Msg
,
1178 TranslateMessage(&Msg
);
1179 DispatchMessage(&Msg
);
1183 DestroyWindow(hMainWnd
);
1188 DPRINT("Failed to create application window (LastError: %d)!\n", GetLastError());
1191 UnregisterApplicationClasses();
1195 DPRINT("Failed to register application classes (LastError: %d)!\n", GetLastError());
1198 if (lpAppTitle
!= NULL
)
1200 LocalFree(lpAppTitle
);
1207 DPRINT("Unable to open the Volume Control registry key!\n");