[SNDVOL32] Implement the dialog resize code for the 'Advanced Controls' menu item and prepare for clicks on the 'Advanced' button.

This commit is contained in:
Eric Kohl 2019-02-18 00:58:28 +01:00
parent fe5c50e182
commit 95ed44ef63
3 changed files with 71 additions and 95 deletions

View file

@ -631,7 +631,19 @@ EnumConnectionsCallback(
else else
{ {
if (PrefContext->MixerWindow->Mode == NORMAL_MODE) if (PrefContext->MixerWindow->Mode == NORMAL_MODE)
{
PrefContext->MixerWindow->bHasExtendedControls = TRUE; PrefContext->MixerWindow->bHasExtendedControls = TRUE;
wID = (PrefContext->MixerWindow->DialogCount + 1) * IDC_LINE_ADVANCED;
/* get dialog control */
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
if (hDlgCtrl != NULL)
{
ShowWindow(hDlgCtrl,
PrefContext->MixerWindow->bShowExtendedControls ? SW_SHOWNORMAL : SW_HIDE);
}
}
} }
} }
@ -658,26 +670,34 @@ LoadDialogCtrls(
{ {
HWND hDlgCtrl; HWND hDlgCtrl;
RECT statusRect; RECT statusRect;
UINT i;
LONG dy;
/* set dialog count to zero */ /* set dialog count to zero */
PrefContext->MixerWindow->DialogCount = 0; PrefContext->MixerWindow->DialogCount = 0;
PrefContext->MixerWindow->bHasExtendedControls = FALSE;
SetRectEmpty(&PrefContext->MixerWindow->rect); SetRectEmpty(&PrefContext->MixerWindow->rect);
/* enumerate controls */ /* enumerate controls */
SndMixerEnumConnections(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, EnumConnectionsCallback, (PVOID)PrefContext); SndMixerEnumConnections(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, EnumConnectionsCallback, (PVOID)PrefContext);
if (PrefContext->MixerWindow->bHasExtendedControls) /* Update the 'Advanced Controls' menu item */
{ EnableMenuItem(GetMenu(PrefContext->MixerWindow->hWnd),
EnableMenuItem(GetMenu(PrefContext->MixerWindow->hWnd), IDM_ADVANCED_CONTROLS, MF_BYCOMMAND | MF_ENABLED); IDM_ADVANCED_CONTROLS,
} MF_BYCOMMAND | (PrefContext->MixerWindow->bHasExtendedControls ? MF_ENABLED : MF_GRAYED));
/* Add some height for the status bar */
if (PrefContext->MixerWindow->hStatusBar) if (PrefContext->MixerWindow->hStatusBar)
{ {
GetWindowRect(PrefContext->MixerWindow->hStatusBar, &statusRect); GetWindowRect(PrefContext->MixerWindow->hStatusBar, &statusRect);
PrefContext->MixerWindow->rect.bottom += (statusRect.bottom - statusRect.top); PrefContext->MixerWindow->rect.bottom += (statusRect.bottom - statusRect.top);
} }
/* Add height of the 'Advanced' button */
dy = MulDiv(ADVANCED_BUTTON_HEIGHT, PrefContext->MixerWindow->baseUnit.cy, 8);
if (PrefContext->MixerWindow->bShowExtendedControls && PrefContext->MixerWindow->bHasExtendedControls)
PrefContext->MixerWindow->rect.bottom += dy;
/* now move the window */ /* now move the window */
AdjustWindowRect(&PrefContext->MixerWindow->rect, WS_DLGFRAME | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, TRUE); AdjustWindowRect(&PrefContext->MixerWindow->rect, WS_DLGFRAME | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, TRUE);
SetWindowPos(PrefContext->MixerWindow->hWnd, HWND_TOP, PrefContext->MixerWindow->rect.left, PrefContext->MixerWindow->rect.top, PrefContext->MixerWindow->rect.right - PrefContext->MixerWindow->rect.left, PrefContext->MixerWindow->rect.bottom - PrefContext->MixerWindow->rect.top, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(PrefContext->MixerWindow->hWnd, HWND_TOP, PrefContext->MixerWindow->rect.left, PrefContext->MixerWindow->rect.top, PrefContext->MixerWindow->rect.right - PrefContext->MixerWindow->rect.left, PrefContext->MixerWindow->rect.bottom - PrefContext->MixerWindow->rect.top, SWP_NOMOVE | SWP_NOZORDER);
@ -694,8 +714,28 @@ LoadDialogCtrls(
SWP_NOZORDER); SWP_NOZORDER);
} }
/* Resize the vertical line separators */
for (i = 0; i < PrefContext->MixerWindow->DialogCount; i++)
{
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, (i + 1) * IDC_LINE_SEP);
if (hDlgCtrl != NULL)
{
GetWindowRect(hDlgCtrl, &statusRect);
if (PrefContext->MixerWindow->bShowExtendedControls && PrefContext->MixerWindow->bHasExtendedControls)
statusRect.bottom += dy;
SetWindowPos(hDlgCtrl,
HWND_TOP,
0,
0,
statusRect.right - statusRect.left,
statusRect.bottom - statusRect.top,
SWP_NOMOVE | SWP_NOZORDER);
}
}
/* Hide the last line separator */ /* Hide the last line separator */
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, IDC_LINE_SEP * PrefContext->MixerWindow->DialogCount /*PrefContext->Count*/); hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, IDC_LINE_SEP * PrefContext->MixerWindow->DialogCount);
if (hDlgCtrl != NULL) if (hDlgCtrl != NULL)
{ {
ShowWindow(hDlgCtrl, SW_HIDE); ShowWindow(hDlgCtrl, SW_HIDE);

View file

@ -873,78 +873,6 @@ done:
return TRUE; return TRUE;
} }
static VOID
ResizeMixerWindow(
PMIXER_WINDOW MixerWindow)
{
RECT statusRect;
HWND hDlgCtrl;
UINT i;
LONG dy;
if (MixerWindow->Mode != NORMAL_MODE)
return;
if (MixerWindow->bHasExtendedControls == FALSE)
return;
if (MixerWindow->hStatusBar)
{
GetWindowRect(MixerWindow->hStatusBar, &statusRect);
}
/* Height of the 'Advanced' button in dialog units plus 2 units bottom space */
#define BUTTON_HEIGHT 16
dy = MulDiv(BUTTON_HEIGHT, MixerWindow->baseUnit.cy, 8);
if (MixerWindow->bShowExtendedControls)
MixerWindow->rect.bottom += dy;
else
MixerWindow->rect.bottom -= dy;
SetWindowPos(MixerWindow->hWnd,
HWND_TOP,
MixerWindow->rect.left,
MixerWindow->rect.top,
MixerWindow->rect.right - MixerWindow->rect.left,
MixerWindow->rect.bottom - MixerWindow->rect.top,
SWP_NOMOVE | SWP_NOZORDER);
if (MixerWindow->hStatusBar)
{
SetWindowPos(MixerWindow->hStatusBar,
HWND_TOP,
statusRect.left,
MixerWindow->rect.bottom - (statusRect.bottom - statusRect.top),
MixerWindow->rect.right - MixerWindow->rect.left,
statusRect.bottom - statusRect.top,
SWP_NOZORDER);
}
for (i = 0; i < MixerWindow->DialogCount; i++)
{
hDlgCtrl = GetDlgItem(MixerWindow->hWnd, IDC_LINE_SEP * i);
if (hDlgCtrl != NULL)
{
GetWindowRect(hDlgCtrl, &statusRect);
if (MixerWindow->bShowExtendedControls)
statusRect.bottom += dy;
else
statusRect.bottom -= dy;
SetWindowPos(hDlgCtrl,
HWND_TOP,
0,
0,
statusRect.right - statusRect.left,
statusRect.bottom - statusRect.top,
SWP_NOMOVE | SWP_NOZORDER);
}
}
}
static LRESULT CALLBACK static LRESULT CALLBACK
MainWindowProc(HWND hwnd, MainWindowProc(HWND hwnd,
UINT uMsg, UINT uMsg,
@ -1037,7 +965,7 @@ MainWindowProc(HWND hwnd,
CheckMenuItem(GetMenu(hwnd), CheckMenuItem(GetMenu(hwnd),
IDM_ADVANCED_CONTROLS, IDM_ADVANCED_CONTROLS,
MF_BYCOMMAND | (MixerWindow->bShowExtendedControls ? MF_CHECKED : MF_UNCHECKED)); MF_BYCOMMAND | (MixerWindow->bShowExtendedControls ? MF_CHECKED : MF_UNCHECKED));
ResizeMixerWindow(MixerWindow); RebuildMixerWindowControls(&Preferences);
break; break;
case IDM_EXIT: case IDM_EXIT:
@ -1063,7 +991,9 @@ MainWindowProc(HWND hwnd,
CtrlID = LOWORD(wParam); CtrlID = LOWORD(wParam);
/* check if the message is from the line switch */ /* check if the message is from the line switch */
if (HIWORD(wParam) == BN_CLICKED && (CtrlID % IDC_LINE_SWITCH == 0)) if (HIWORD(wParam) == BN_CLICKED)
{
if (CtrlID % IDC_LINE_SWITCH == 0)
{ {
/* compute line offset */ /* compute line offset */
LineOffset = CtrlID / IDC_LINE_SWITCH; LineOffset = CtrlID / IDC_LINE_SWITCH;
@ -1083,9 +1013,13 @@ MainWindowProc(HWND hwnd,
SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context); SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context);
} }
} }
} else if (CtrlID % IDC_LINE_ADVANCED == 0)
{
} }
}
}
}
break; break;
} }

View file

@ -28,6 +28,8 @@
#define PLAY_MIXER 0 #define PLAY_MIXER 0
#define RECORD_MIXER 1 #define RECORD_MIXER 1
#define ADVANCED_BUTTON_HEIGHT 16
typedef enum _WINDOW_MODE typedef enum _WINDOW_MODE
{ {
NORMAL_MODE, NORMAL_MODE,