[SNDVOL32] In record mode, rename the 'Mute' autocheckbox to 'Select', turn it into...
[reactos.git] / base / applications / sndvol32 / sndvol32.c
index 7f3d118..64ce3ac 100644 (file)
@@ -591,7 +591,6 @@ DlgPreferencesProc(HWND hwndDlg,
     return 0;
 }
 
-
 /******************************************************************************/
 
 static VOID
@@ -659,7 +658,7 @@ SetVolumeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
     {
         if (Context->bVertical)
         {
-            if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
+            if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
             {
                 DWORD LineOffset, volumePosition, balancePosition;
                 DWORD volumeStep, balanceStep;
@@ -725,7 +724,7 @@ SetVolumeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVOID Ctx)
         }
         else if (Context->bSwitch)
         {
-            if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
+            if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE)
             {
                 /* set up details */
                 bDetails.fValue = Context->SliderPos;
@@ -784,7 +783,7 @@ MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVO
     {
         if (Control[Index].dwControlID == PtrToUlong(Context))
         {
-            if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
+            if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE)
             {
                 MIXERCONTROLDETAILS_BOOLEAN Details;
 
@@ -795,7 +794,7 @@ MixerControlChangeCallback(PSND_MIXER Mixer, DWORD LineID, LPMIXERLINE Line, PVO
                     UpdateDialogLineSwitchControl(&Preferences, Line, Details.fValue);
                 }
             }
-            else if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
+            else if (Control[Index].dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME)
             {
                 /* get volume control details */
                 if (SndMixerGetVolumeControlDetails(Preferences.MixerWindow->Mixer, Control[Index].dwControlID, Line->cChannels, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)pVolumeDetails) != -1)
@@ -873,7 +872,6 @@ done:
     return TRUE;
 }
 
-
 static LRESULT CALLBACK
 MainWindowProc(HWND hwnd,
                UINT uMsg,
@@ -894,7 +892,7 @@ MainWindowProc(HWND hwnd,
 
             switch (LOWORD(wParam))
             {
-                case IDC_PROPERTIES:
+                case IDM_PROPERTIES:
                 {
                     PREFERENCES_CONTEXT Pref;
 
@@ -938,9 +936,6 @@ MainWindowProc(HWND hwnd,
                         /* use new selected mixer */
                         Preferences.MixerWindow->Mixer = Pref.Mixer;
 
-                        /* rebuild dialog controls */
-                        RebuildMixerWindowControls(&Preferences);
-
                         /* create status window */
                         if (MixerWindow->Mode == NORMAL_MODE)
                         {
@@ -957,17 +952,28 @@ MainWindowProc(HWND hwnd,
                                     (LPARAM)szProduct);
                             }
                         }
+
+                        /* rebuild dialog controls */
+                        RebuildMixerWindowControls(&Preferences);
                     }
                     break;
                 }
 
-                case IDC_EXIT:
+                case IDM_ADVANCED_CONTROLS:
+                    MixerWindow->bShowExtendedControls = !MixerWindow->bShowExtendedControls;
+                    CheckMenuItem(GetMenu(hwnd),
+                                  IDM_ADVANCED_CONTROLS,
+                                  MF_BYCOMMAND | (MixerWindow->bShowExtendedControls ? MF_CHECKED : MF_UNCHECKED));
+                    RebuildMixerWindowControls(&Preferences);
+                    break;
+
+                case IDM_EXIT:
                 {
                     PostQuitMessage(0);
                     break;
                 }
 
-                case IDC_ABOUT:
+                case IDM_ABOUT:
                 {
                     HICON hAppIcon = (HICON)GetClassLongPtrW(hwnd,
                                                              GCLP_HICON);
@@ -984,28 +990,70 @@ 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;
+                            if (Preferences.MixerWindow->Mixer->MixerId == PLAY_MIXER)
+                            {
+                                /* 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;
+
+                                    /* set volume */
+                                    SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context);
+                                }
+                            }
+                            else if (Preferences.MixerWindow->Mixer->MixerId == RECORD_MIXER)
+                            {
+                                UINT i;
 
-                        /* get line name */
-                        if (GetDlgItemTextW(hwnd, CtrlID, Context.LineName, MIXER_LONG_NAME_CHARS) != 0)
+                                for (i = 0; i < Preferences.MixerWindow->DialogCount; i++)
+                                {
+                                    SendDlgItemMessageW(hwnd, (i + 1) * IDC_LINE_SWITCH, BM_SETCHECK, (WPARAM)((i + 1) == LineOffset), 0);
+                                }
+                            }
+                        }
+                        else if (CtrlID % IDC_LINE_ADVANCED == 0)
                         {
-                            /* setup context */
-                            Context.SliderPos = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0);
-                            Context.bVertical = FALSE;
-                            Context.bSwitch = TRUE;
+                            ADVANCED_CONTEXT AdvancedContext;
+
+                            /* compute line offset */
+                            LineOffset = CtrlID / IDC_LINE_ADVANCED;
+
+                            /* compute window id of line name static control */
+                            CtrlID = LineOffset * IDC_LINE_NAME;
 
-                            /* set volume */
-                            SndMixerEnumConnections(Preferences.MixerWindow->Mixer, Preferences.SelectedLine, SetVolumeCallback, (LPVOID)&Context);
+                            /* get line name */
+                            if (GetDlgItemTextW(hwnd, CtrlID, AdvancedContext.LineName, MIXER_LONG_NAME_CHARS) != 0)
+                            {
+                                AdvancedContext.MixerWindow = Preferences.MixerWindow;
+                                AdvancedContext.Mixer = Preferences.MixerWindow->Mixer;
+                                AdvancedContext.Line = SndMixerGetLineByName(Preferences.MixerWindow->Mixer,
+                                                                             Preferences.SelectedLine,
+                                                                             AdvancedContext.LineName);
+                                if (AdvancedContext.Line)
+                                {
+                                    DialogBoxParam(hAppInstance,
+                                                   MAKEINTRESOURCE(IDD_ADVANCED),
+                                                   hwnd,
+                                                   AdvancedDlgProc,
+                                                   (LPARAM)&AdvancedContext);
+                                }
+                            }
                         }
                     }
                 }
-
             }
             break;
         }
@@ -1160,13 +1208,8 @@ MainWindowProc(HWND hwnd,
                 /* copy product */
                 wcscpy(Preferences.DeviceName, szProduct);
 
-                if (!RebuildMixerWindowControls(&Preferences))
-                {
-                    DPRINT("Rebuilding mixer window controls failed!\n");
-                    SndMixerDestroy(MixerWindow->Mixer);
-                    MixerWindow->Mixer = NULL;
-                    Result = -1;
-                }
+                /* Disable the 'Advanced Controls' menu item */
+                EnableMenuItem(GetMenu(hwnd), IDM_ADVANCED_CONTROLS, MF_BYCOMMAND | MF_GRAYED);
 
                 /* create status window */
                 if (MixerWindow->Mode == NORMAL_MODE)
@@ -1184,8 +1227,13 @@ MainWindowProc(HWND hwnd,
                     }
                 }
 
-                /* Disable the 'Advanced Controls' menu item */
-                EnableMenuItem(GetMenu(hwnd), IDC_ADVANCED_CONTROLS, MF_BYCOMMAND | MF_GRAYED);
+                if (!RebuildMixerWindowControls(&Preferences))
+                {
+                    DPRINT("Rebuilding mixer window controls failed!\n");
+                    SndMixerDestroy(MixerWindow->Mixer);
+                    MixerWindow->Mixer = NULL;
+                    Result = -1;
+                }
             }
             break;
         }