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>
14 PADVANCED_CONTEXT Context
)
16 WCHAR szRawTitle
[256], szCookedTitle
[256];
17 MIXERCONTROLDETAILS_UNSIGNED UnsignedDetails
;
18 LPMIXERCONTROL Control
= NULL
;
19 UINT ControlCount
= 0, Index
;
20 DWORD i
, dwStep
, dwPosition
;
22 /* Set the dialog title */
23 LoadStringW(hAppInstance
, IDS_ADVANCED_CONTROLS
, szRawTitle
, ARRAYSIZE(szRawTitle
));
24 StringCchPrintfW(szCookedTitle
, ARRAYSIZE(szCookedTitle
), szRawTitle
, Context
->LineName
);
25 SetWindowTextW(hwndDlg
, szCookedTitle
);
27 /* Disable the tone controls */
28 for (i
= IDC_ADV_BASS_LOW
; i
<= IDC_ADV_TREBLE_SLIDER
; i
++)
29 EnableWindow(GetDlgItem(hwndDlg
, i
), FALSE
);
31 /* Initialize the bass and treble trackbars */
32 SendDlgItemMessageW(hwndDlg
, IDC_ADV_BASS_SLIDER
, TBM_SETRANGE
, (WPARAM
)TRUE
, (LPARAM
)MAKELONG(VOLUME_MIN
, VOLUME_MAX
));
33 SendDlgItemMessageW(hwndDlg
, IDC_ADV_TREBLE_SLIDER
, TBM_SETRANGE
, (WPARAM
)TRUE
, (LPARAM
)MAKELONG(VOLUME_MIN
, VOLUME_MAX
));
34 SendDlgItemMessageW(hwndDlg
, IDC_ADV_BASS_SLIDER
, TBM_SETPAGESIZE
, 0, (LPARAM
)VOLUME_PAGE_SIZE
);
35 SendDlgItemMessageW(hwndDlg
, IDC_ADV_TREBLE_SLIDER
, TBM_SETPAGESIZE
, 0, (LPARAM
)VOLUME_PAGE_SIZE
);
36 SendDlgItemMessageW(hwndDlg
, IDC_ADV_BASS_SLIDER
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)0);
37 SendDlgItemMessageW(hwndDlg
, IDC_ADV_TREBLE_SLIDER
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)0);
39 /* Calculate and set ticks */
40 dwStep
= (VOLUME_MAX
/ (VOLUME_TICKS
+ 1));
41 if (VOLUME_MAX
% (VOLUME_TICKS
+ 1) != 0)
43 for (i
= dwStep
; i
< VOLUME_MAX
; i
+= dwStep
)
45 SendDlgItemMessageW(hwndDlg
, IDC_ADV_BASS_SLIDER
, TBM_SETTIC
, 0, (LPARAM
)i
);
46 SendDlgItemMessageW(hwndDlg
, IDC_ADV_TREBLE_SLIDER
, TBM_SETTIC
, 0, (LPARAM
)i
);
49 /* Hide the other controls */
50 for (i
= IDC_ADV_OTHER_CONTROLS
; i
<= IDC_ADV_OTHER_CHECK2
; i
++)
51 ShowWindow(GetDlgItem(hwndDlg
, i
), SW_HIDE
);
53 if (SndMixerQueryControls(Context
->Mixer
, &ControlCount
, Context
->Line
, &Control
))
55 for (Index
= 0; Index
< ControlCount
; Index
++)
57 if (Control
[Index
].dwControlType
== MIXERCONTROL_CONTROLTYPE_BASS
)
59 if (SndMixerGetVolumeControlDetails(Context
->Mixer
, Control
[Index
].dwControlID
, 1, sizeof(MIXERCONTROLDETAILS_UNSIGNED
), (LPVOID
)&UnsignedDetails
) != -1)
61 for (i
= IDC_ADV_BASS_LOW
; i
<= IDC_ADV_BASS_SLIDER
; i
++)
62 EnableWindow(GetDlgItem(hwndDlg
, i
), TRUE
);
64 dwStep
= (Control
[Index
].Bounds
.dwMaximum
- Control
[Index
].Bounds
.dwMinimum
) / (VOLUME_MAX
- VOLUME_MIN
);
65 dwPosition
= (UnsignedDetails
.dwValue
- Control
[Index
].Bounds
.dwMinimum
) / dwStep
;
66 SendDlgItemMessageW(hwndDlg
, IDC_ADV_BASS_SLIDER
, TBM_SETPOS
, (WPARAM
)TRUE
, dwPosition
);
69 else if (Control
[Index
].dwControlType
== MIXERCONTROL_CONTROLTYPE_TREBLE
)
71 if (SndMixerGetVolumeControlDetails(Context
->Mixer
, Control
[Index
].dwControlID
, 1, sizeof(MIXERCONTROLDETAILS_UNSIGNED
), (LPVOID
)&UnsignedDetails
) != -1)
73 for (i
= IDC_ADV_TREBLE_LOW
; i
<= IDC_ADV_TREBLE_SLIDER
; i
++)
74 EnableWindow(GetDlgItem(hwndDlg
, i
), TRUE
);
76 dwStep
= (Control
[Index
].Bounds
.dwMaximum
- Control
[Index
].Bounds
.dwMinimum
) / (VOLUME_MAX
- VOLUME_MIN
);
77 dwPosition
= (UnsignedDetails
.dwValue
- Control
[Index
].Bounds
.dwMinimum
) / dwStep
;
78 SendDlgItemMessageW(hwndDlg
, IDC_ADV_TREBLE_SLIDER
, TBM_SETPOS
, (WPARAM
)TRUE
, dwPosition
);
81 else if (Control
[Index
].dwControlType
!= MIXERCONTROL_CONTROLTYPE_VOLUME
&&
82 Control
[Index
].dwControlType
!= MIXERCONTROL_CONTROLTYPE_MUTE
)
84 ShowWindow(GetDlgItem(hwndDlg
, IDC_ADV_OTHER_CONTROLS
), SW_SHOWNORMAL
);
85 ShowWindow(GetDlgItem(hwndDlg
, IDC_ADV_OTHER_TEXT
), SW_SHOWNORMAL
);
91 HeapFree(GetProcessHeap(), 0, Control
);
104 PADVANCED_CONTEXT Context
;
109 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)lParam
);
110 Context
= (PADVANCED_CONTEXT
)((LONG_PTR
)lParam
);
111 OnInitDialog(hwndDlg
, Context
);
115 switch (LOWORD(wParam
))
118 EndDialog(hwndDlg
, IDOK
);
124 EndDialog(hwndDlg
, IDCANCEL
);