From 95ed44ef63d767a2bda03fef455b795526f265aa Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 18 Feb 2019 00:58:28 +0100 Subject: [PATCH] [SNDVOL32] Implement the dialog resize code for the 'Advanced Controls' menu item and prepare for clicks on the 'Advanced' button. --- base/applications/sndvol32/dialog.c | 52 +++++++++++-- base/applications/sndvol32/sndvol32.c | 108 +++++--------------------- base/applications/sndvol32/sndvol32.h | 2 + 3 files changed, 69 insertions(+), 93 deletions(-) diff --git a/base/applications/sndvol32/dialog.c b/base/applications/sndvol32/dialog.c index d14a3240987..f0d5d39a84d 100644 --- a/base/applications/sndvol32/dialog.c +++ b/base/applications/sndvol32/dialog.c @@ -631,7 +631,19 @@ EnumConnectionsCallback( else { if (PrefContext->MixerWindow->Mode == NORMAL_MODE) + { 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; RECT statusRect; + UINT i; + LONG dy; /* set dialog count to zero */ PrefContext->MixerWindow->DialogCount = 0; - + PrefContext->MixerWindow->bHasExtendedControls = FALSE; SetRectEmpty(&PrefContext->MixerWindow->rect); /* enumerate controls */ SndMixerEnumConnections(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, EnumConnectionsCallback, (PVOID)PrefContext); - if (PrefContext->MixerWindow->bHasExtendedControls) - { - EnableMenuItem(GetMenu(PrefContext->MixerWindow->hWnd), IDM_ADVANCED_CONTROLS, MF_BYCOMMAND | MF_ENABLED); - } + /* Update the 'Advanced Controls' menu item */ + EnableMenuItem(GetMenu(PrefContext->MixerWindow->hWnd), + IDM_ADVANCED_CONTROLS, + MF_BYCOMMAND | (PrefContext->MixerWindow->bHasExtendedControls ? MF_ENABLED : MF_GRAYED)); + /* Add some height for the status bar */ if (PrefContext->MixerWindow->hStatusBar) { GetWindowRect(PrefContext->MixerWindow->hStatusBar, &statusRect); 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 */ 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); @@ -694,8 +714,28 @@ LoadDialogCtrls( 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 */ - 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) { ShowWindow(hDlgCtrl, SW_HIDE); diff --git a/base/applications/sndvol32/sndvol32.c b/base/applications/sndvol32/sndvol32.c index bfb640981c7..5e9616d67ea 100644 --- a/base/applications/sndvol32/sndvol32.c +++ b/base/applications/sndvol32/sndvol32.c @@ -873,78 +873,6 @@ done: 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 MainWindowProc(HWND hwnd, UINT uMsg, @@ -1037,7 +965,7 @@ MainWindowProc(HWND hwnd, CheckMenuItem(GetMenu(hwnd), IDM_ADVANCED_CONTROLS, MF_BYCOMMAND | (MixerWindow->bShowExtendedControls ? MF_CHECKED : MF_UNCHECKED)); - ResizeMixerWindow(MixerWindow); + RebuildMixerWindowControls(&Preferences); break; case IDM_EXIT: @@ -1063,28 +991,34 @@ MainWindowProc(HWND hwnd, CtrlID = LOWORD(wParam); /* check if the message is from the line switch */ - if (HIWORD(wParam) == BN_CLICKED && (CtrlID % IDC_LINE_SWITCH == 0)) + if (HIWORD(wParam) == BN_CLICKED) { - /* compute line offset */ - LineOffset = CtrlID / IDC_LINE_SWITCH; + if (CtrlID % IDC_LINE_SWITCH == 0) + { + /* compute line offset */ + LineOffset = CtrlID / IDC_LINE_SWITCH; + + /* compute window id of line name static control */ + CtrlID = LineOffset * IDC_LINE_NAME; - /* compute window id of line name static control */ - CtrlID = LineOffset * IDC_LINE_NAME; + /* get line name */ + if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0) + { + /* setup context */ + Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0); + Context.bVertical = FALSE; + Context.bSwitch = TRUE; - /* get line name */ - if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0) + /* set volume */ + SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context); + } + } + else if (CtrlID % IDC_LINE_ADVANCED == 0) { - /* setup context */ - Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0); - Context.bVertical = FALSE; - Context.bSwitch = TRUE; - /* set volume */ - SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context); } } } - } break; } diff --git a/base/applications/sndvol32/sndvol32.h b/base/applications/sndvol32/sndvol32.h index 0e9a0ffd1f9..201e4f0e18a 100644 --- a/base/applications/sndvol32/sndvol32.h +++ b/base/applications/sndvol32/sndvol32.h @@ -28,6 +28,8 @@ #define PLAY_MIXER 0 #define RECORD_MIXER 1 +#define ADVANCED_BUTTON_HEIGHT 16 + typedef enum _WINDOW_MODE { NORMAL_MODE, -- 2.17.1