/* sound.c Sound menu stuff Puts up a list of all the sounds in the [sounds] section of win.ini and plays the selected one */ #include #include #include #include #include "PlaySnd.h" #define KEYBUFSIZE 2048 LONG SoundDlgProc(HWND hDlg, UINT msg, DWORD wParam, LONG lParam); typedef struct SoundNameAlias { LPSTR pName; UINT alias; } SOUNDNAMEALIAS; static SOUNDNAMEALIAS sss[] = {"System"}; static SOUNDNAMEALIAS SNA[] = { "SystemAsterisk", sndAlias('S', '*') , "SystemQuestion", sndAlias('S', '?') , "SystemHand", sndAlias('S', 'H') , "SystemExit", sndAlias('S', 'E') , "SystemStartup", sndAlias('S', 'S') , "SystemWelcome", sndAlias('S', 'W') , "SystemExclamation", sndAlias('S', '!') , "SystemDefault", sndAlias('S', 'D') }; #define NUMSYSTEMSOUNDS (sizeof(SNA)/sizeof(SOUNDNAMEALIAS)) UINT TranslateNameToAlias(LPSTR name) { UINT n; for (n=0; n"); } } LONG SoundDlgProc(HWND hDlg, UINT msg, DWORD wParam, LONG lParam) { LPSTR lpBuf, lpKey; DWORD dwChars; // dprintf4(("SoundDlgProc: %8.8XH, %8.8XH, %8.8XH", msg, wParam, lParam)); switch (msg) { case WM_INITDIALOG: // fill the listbox with the keys in the [sounds] // section of win.ini // allocate a buffer to put the keys in WinEval(lpBuf = (LPSTR) GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, KEYBUFSIZE)); // get the key list dwChars = GetProfileString("sounds", NULL, "", lpBuf, KEYBUFSIZE); dprintf4(("%lu chars read from [sounds] section", dwChars)); if (dwChars > 0) { // add each entry to the list box lpKey = lpBuf; while (*lpKey) { // TEMPORARY SECTION if (lstrcmpi((LPCTSTR)lpKey, "enable")) // if not ENABLE // END OF TEMPORARY SECTION SendMessage(GetDlgItem(hDlg, IDSND_LIST), LB_ADDSTRING, 0, (LONG)lpKey); lpKey += strlen(lpKey) + 1; } } else { // show there aren't any SendMessage(GetDlgItem(hDlg, IDSND_LIST), LB_ADDSTRING, 0, (LONG)(LPSTR)"[none]"); } SendDlgItemMessage(hDlg, IDSND_SOUNDNAME, WM_SETTEXT, 0, (LPARAM)""); if (bSync) { // Set the initial state of the Sync checkbox from global flag SendDlgItemMessage(hDlg, IDSND_SYNC, BM_SETCHECK, 1, 0); } if (!bNoWait) { // Set the initial state of the Wait checkbox from global flag SendDlgItemMessage(hDlg, IDSND_WAIT, BM_SETCHECK, 1, 0); } GlobalFree((HANDLE)lpBuf); // disable the play button till we get a selection EnableWindow(GetDlgItem(hDlg, IDSND_PLAY), FALSE); break; case WM_COMMAND: dprintf4(("WM_COMMAND: %08lXH, %08lX", wParam, lParam)); switch (LOWORD(wParam)) { case IDOK: EndDialog(hDlg, TRUE); break; case IDSND_PLAY: // get the current selection and try to play it PlaySelection(hDlg); break; case IDSND_LIST: switch (HIWORD(wParam)){ case LBN_SELCHANGE: // enable the play button EnableWindow(GetDlgItem(hDlg, IDSND_PLAY), TRUE); dprintf3(("Play button enabled")); // Set the current sound name SetSoundName(hDlg); break; case LBN_DBLCLK: PlaySelection(hDlg); break; default: break; } break; default: break; } break; default: return FALSE; // say we didn't handle it break; } return TRUE; // say we handled it }