mirror of
https://github.com/reactos/reactos.git
synced 2026-05-31 16:31:07 +08:00
[SNDVOL32] Deduplicate dialog control retrieval code
This commit is contained in:
@@ -767,69 +767,20 @@ LoadDialogCtrls(
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
UpdateDialogLineSwitchControl(
|
||||
HWND
|
||||
GetLineDialogControl(
|
||||
PPREFERENCES_CONTEXT PrefContext,
|
||||
LPMIXERLINE Line,
|
||||
LONG fValue)
|
||||
DWORD dwDialogID)
|
||||
{
|
||||
DWORD Index;
|
||||
DWORD wID;
|
||||
HWND hDlgCtrl;
|
||||
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
||||
|
||||
/* find the index of this line */
|
||||
for (Index = 0; Index < PrefContext->MixerWindow->DialogCount; Index++)
|
||||
{
|
||||
/* get id */
|
||||
wID = (Index + 1) * IDC_LINE_NAME;
|
||||
|
||||
if (GetDlgItemText(PrefContext->MixerWindow->hWnd, wID, LineName, MIXER_LONG_NAME_CHARS) == 0)
|
||||
{
|
||||
/* failed to retrieve id */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check if the line name matches */
|
||||
if (!_wcsicmp(LineName, Line->szName))
|
||||
{
|
||||
/* found matching line name */
|
||||
wID = (Index + 1) * IDC_LINE_SWITCH;
|
||||
|
||||
/* get dialog control */
|
||||
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
||||
|
||||
if (hDlgCtrl != NULL)
|
||||
{
|
||||
/* check state */
|
||||
if (SendMessageW(hDlgCtrl, BM_GETCHECK, 0, 0) != fValue)
|
||||
{
|
||||
/* update control state */
|
||||
SendMessageW(hDlgCtrl, BM_SETCHECK, (WPARAM)fValue, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
UpdateDialogLineSliderControl(
|
||||
PPREFERENCES_CONTEXT PrefContext,
|
||||
LPMIXERLINE Line,
|
||||
DWORD dwDialogID,
|
||||
DWORD Position)
|
||||
{
|
||||
DWORD Index;
|
||||
DWORD wID;
|
||||
HWND hDlgCtrl;
|
||||
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
||||
|
||||
/* find the index of this line */
|
||||
for (Index = 0; Index < PrefContext->MixerWindow->DialogCount; Index++)
|
||||
{
|
||||
/* get id */
|
||||
wID = (Index + 1) * IDC_LINE_NAME;
|
||||
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
||||
DWORD wID = (Index + 1) * IDC_LINE_NAME;
|
||||
|
||||
if (GetDlgItemText(PrefContext->MixerWindow->hWnd, wID, LineName, MIXER_LONG_NAME_CHARS) == 0)
|
||||
{
|
||||
@@ -843,20 +794,48 @@ UpdateDialogLineSliderControl(
|
||||
/* found matching line name */
|
||||
wID = (Index + 1) * dwDialogID;
|
||||
|
||||
/* get dialog control */
|
||||
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
||||
|
||||
if (hDlgCtrl != NULL)
|
||||
{
|
||||
/* check state */
|
||||
LRESULT OldPosition = SendMessageW(hDlgCtrl, TBM_GETPOS, 0, 0);
|
||||
if (OldPosition != Position)
|
||||
{
|
||||
/* update control state */
|
||||
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position);
|
||||
}
|
||||
}
|
||||
break;
|
||||
return GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
UpdateDialogLineSwitchControl(
|
||||
PPREFERENCES_CONTEXT PrefContext,
|
||||
LPMIXERLINE Line,
|
||||
LONG fValue)
|
||||
{
|
||||
HWND hDlgCtrl = GetLineDialogControl(PrefContext, Line, IDC_LINE_SWITCH);
|
||||
|
||||
if (hDlgCtrl != NULL && SendMessageW(hDlgCtrl, BM_GETCHECK, 0, 0) != fValue)
|
||||
SendMessageW(hDlgCtrl, BM_SETCHECK, (WPARAM)fValue, 0);
|
||||
}
|
||||
|
||||
DWORD
|
||||
GetDialogLineSliderCurrentPosition(
|
||||
PPREFERENCES_CONTEXT PrefContext,
|
||||
LPMIXERLINE Line,
|
||||
DWORD dwDialogID)
|
||||
{
|
||||
HWND hDlgCtrl = GetLineDialogControl(PrefContext, Line, dwDialogID);
|
||||
|
||||
return hDlgCtrl != NULL
|
||||
? SendMessageW(hDlgCtrl, TBM_GETPOS, 0, 0)
|
||||
: 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
UpdateDialogLineSliderControl(
|
||||
PPREFERENCES_CONTEXT PrefContext,
|
||||
LPMIXERLINE Line,
|
||||
DWORD dwDialogID,
|
||||
DWORD Position)
|
||||
{
|
||||
HWND hDlgCtrl = GetLineDialogControl(PrefContext, Line, dwDialogID);
|
||||
BOOL isPositionChanged = GetDialogLineSliderCurrentPosition(PrefContext, Line, dwDialogID) != Position;
|
||||
|
||||
if (hDlgCtrl != NULL && isPositionChanged)
|
||||
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user