34d1d62093a1fd3b839d933643ee3492bffb7306
[reactos.git] / base / applications / sndvol32 / advanced.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Sound Volume Control
4 * FILE: base/applications/sndvol32/advanced.c
5 * PROGRAMMERS: Eric Kohl <eric.kohl@reactos.org>
6 */
7
8 #include "sndvol32.h"
9
10 static
11 VOID
12 OnInitDialog(
13 HWND hwndDlg,
14 PADVANCED_CONTEXT Context)
15 {
16 WCHAR szRawTitle[256], szCookedTitle[256];
17 LPMIXERCONTROL Control = NULL;
18 UINT ControlCount = 0, Index, i;
19
20 /* Set the dialog title */
21 LoadStringW(hAppInstance, IDS_ADVANCED_CONTROLS, szRawTitle, ARRAYSIZE(szRawTitle));
22 // swprintf(szCookedTitle, szRawTitle, Context->LineName);
23 StringCchPrintfW(szCookedTitle, ARRAYSIZE(szCookedTitle), szRawTitle, Context->LineName);
24 SetWindowTextW(hwndDlg, szCookedTitle);
25
26 /* Disable the tone controls */
27 for (i = IDC_ADV_BASS_LOW; i<= IDC_ADV_TREBLE_SLIDER; i++)
28 EnableWindow(GetDlgItem(hwndDlg, i), FALSE);
29
30 /* Hide the other controls */
31 for (i = IDC_ADV_OTHER_CONTROLS; i<= IDC_ADV_OTHER_CHECK2; i++)
32 ShowWindow(GetDlgItem(hwndDlg, i), SW_HIDE);
33
34 if (SndMixerQueryControls(Context->Mixer, &ControlCount, Context->Line, &Control))
35 {
36 for (Index = 0; Index < ControlCount; Index++)
37 {
38 if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_BASS)
39 {
40 for (i = IDC_ADV_BASS_LOW; i<= IDC_ADV_BASS_SLIDER; i++)
41 EnableWindow(GetDlgItem(hwndDlg, i), TRUE);
42
43 }
44 else if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_TREBLE)
45 {
46 for (i = IDC_ADV_TREBLE_LOW; i<= IDC_ADV_TREBLE_SLIDER; i++)
47 EnableWindow(GetDlgItem(hwndDlg, i), TRUE);
48
49 }
50 else if (Control[Index].dwControlType != MIXERCONTROL_CONTROLTYPE_VOLUME &&
51 Control[Index].dwControlType != MIXERCONTROL_CONTROLTYPE_MUTE)
52 {
53 ShowWindow(GetDlgItem(hwndDlg, IDC_ADV_OTHER_CONTROLS), SW_SHOWNORMAL);
54 ShowWindow(GetDlgItem(hwndDlg, IDC_ADV_OTHER_TEXT), SW_SHOWNORMAL);
55
56 }
57 }
58
59 /* free controls */
60 HeapFree(GetProcessHeap(), 0, Control);
61 }
62 }
63
64
65 INT_PTR
66 CALLBACK
67 AdvancedDlgProc(
68 HWND hwndDlg,
69 UINT uMsg,
70 WPARAM wParam,
71 LPARAM lParam)
72 {
73 PADVANCED_CONTEXT Context;
74
75 switch (uMsg)
76 {
77 case WM_INITDIALOG:
78 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
79 Context = (PADVANCED_CONTEXT)((LONG_PTR)lParam);
80 OnInitDialog(hwndDlg, Context);
81 return TRUE;
82
83 case WM_COMMAND:
84 switch (LOWORD(wParam))
85 {
86 case IDOK:
87 EndDialog(hwndDlg, IDOK);
88 break;
89 }
90 break;
91
92 case WM_CLOSE:
93 EndDialog(hwndDlg, IDCANCEL);
94 break;
95 }
96
97 return FALSE;
98 }
99
100 /* EOF */