[SNDVOL32] Disable only the 'Play' button, when no audio device is avaiblable.
authorEric Kohl <eric.kohl@reactos.org>
Sun, 24 Feb 2019 15:12:55 +0000 (16:12 +0100)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 24 Feb 2019 15:16:53 +0000 (16:16 +0100)
dll/cpl/mmsys/sounds.c

index 5d89dfd..79ee1f2 100644 (file)
@@ -57,6 +57,7 @@ typedef struct _GLOBAL_DATA
     HIMAGELIST hSoundsImageList;
     PLABEL_MAP pLabelMap;
     PAPP_MAP pAppMap;
+    UINT NumWavOut;
 } GLOBAL_DATA, *PGLOBAL_DATA;
 
 
@@ -1107,11 +1108,11 @@ SoundsDlgProc(HWND hwndDlg,
     {
         case WM_INITDIALOG:
         {
-            UINT NumWavOut = waveOutGetNumDevs();
-
             pGlobalData = (PGLOBAL_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
             SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
 
+            pGlobalData->NumWavOut = waveOutGetNumDevs();
+
             SendMessage(GetDlgItem(hwndDlg, IDC_PLAY_SOUND),
                         BM_SETIMAGE,(WPARAM)IMAGE_ICON,
                         (LPARAM)(HANDLE)LoadIcon(hApplet, MAKEINTRESOURCE(IDI_PLAY_ICON)));
@@ -1127,14 +1128,6 @@ SoundsDlgProc(HWND hwndDlg,
             LoadSoundFiles(hwndDlg);
             ShowSoundScheme(pGlobalData, hwndDlg);
 
-            if (!NumWavOut)
-            {
-                EnableWindow(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), FALSE);
-                EnableWindow(GetDlgItem(hwndDlg, IDC_SAVEAS_BTN),   FALSE);
-                EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_BTN),   FALSE);
-                EnableWindow(GetDlgItem(hwndDlg, IDC_SCHEME_LIST),  FALSE);
-            }
-
             if (wParam == (WPARAM)GetDlgItem(hwndDlg, IDC_SOUND_SCHEME))
                 return TRUE;
             SetFocus(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME));
@@ -1257,7 +1250,7 @@ SoundsDlgProc(HWND hwndDlg,
                                ///
                                _tcscpy(pLabelContext->szValue, (TCHAR*)lResult);
                             }
-                            if (_tcslen((TCHAR*)lResult) && lIndex != 0)
+                            if (_tcslen((TCHAR*)lResult) && lIndex != 0 && pGlobalData->NumWavOut != 0)
                             {
                                 EnableWindow(GetDlgItem(hwndDlg, IDC_PLAY_SOUND), TRUE);
                             }
@@ -1322,7 +1315,8 @@ SoundsDlgProc(HWND hwndDlg,
                         break;
                     }
 
-                    EnableWindow(GetDlgItem(hwndDlg, IDC_PLAY_SOUND), TRUE);
+                    if (pGlobalData->NumWavOut != 0)
+                        EnableWindow(GetDlgItem(hwndDlg, IDC_PLAY_SOUND), TRUE);
 
                     lCount = ComboBox_GetCount(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
                     for (lIndex = 0; lIndex < lCount; lIndex++)