[SNDVOL32] Disable only the 'Play' button, when no audio device is avaiblable.

This commit is contained in:
Eric Kohl
2019-02-24 16:12:55 +01:00
parent 8c90a67da6
commit 722797c779

View 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++)