2 * PROJECT: ReactOS Multimedia Control Panel
3 * FILE: dll/cpl/mmsys/sounds.c
4 * PURPOSE: ReactOS Multimedia Control Panel
5 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
6 * Johannes Anderwald <janderwald@reactos.com>
7 * Dmitry Chapyshev <dmitry@reactos.org>
8 * Victor Martinez Calvo <victor.martinez@reactos.org>
9 * Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
22 typedef struct __LABEL_MAP__
27 struct __APP_MAP__
* AppMap
;
28 struct __LABEL_MAP__
* Next
;
29 } LABEL_MAP
, *PLABEL_MAP
;
31 typedef struct __APP_MAP__
33 TCHAR szName
[MAX_PATH
];
34 TCHAR szDesc
[MAX_PATH
];
35 TCHAR szIcon
[MAX_PATH
];
37 struct __APP_MAP__
*Next
;
41 typedef struct __LABEL_CONTEXT__
45 TCHAR szValue
[MAX_PATH
];
46 struct __LABEL_CONTEXT__
*Next
;
47 } LABEL_CONTEXT
, *PLABEL_CONTEXT
;
49 typedef struct __SOUND_SCHEME_CONTEXT__
51 TCHAR szName
[MAX_PATH
];
52 TCHAR szDesc
[MAX_PATH
];
53 PLABEL_CONTEXT LabelContext
;
54 } SOUND_SCHEME_CONTEXT
, *PSOUND_SCHEME_CONTEXT
;
56 static PLABEL_MAP s_Map
= NULL
;
57 static PAPP_MAP s_App
= NULL
;
59 TCHAR szDefault
[MAX_PATH
];
61 /* A filter string is a list separated by NULL and ends with double NULLs. */
62 LPWSTR
MakeFilter(LPWSTR psz
)
66 ASSERT(psz
[0] != UNICODE_NULL
&&
67 psz
[wcslen(psz
) - 1] == L
'|');
68 for (pch
= psz
; *pch
!= UNICODE_NULL
; pch
++)
70 /* replace vertical bar with NULL */
79 PLABEL_MAP
FindLabel(PAPP_MAP pAppMap
, TCHAR
* szName
)
81 PLABEL_MAP pMap
= s_Map
;
87 if (!_tcscmp(pMap
->szName
, szName
))
93 pMap
= pAppMap
->LabelMap
;
99 if (!_tcscmp(pMap
->szName
, szName
))
105 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
109 pMap
->szName
= pMap
->szDesc
= _tcsdup(szName
);
112 HeapFree(GetProcessHeap(), 0, pMap
);
116 pMap
->AppMap
= pAppMap
;
124 VOID
RemoveLabel(PLABEL_MAP pMap
)
126 PLABEL_MAP pCurMap
= s_Map
;
136 if (pCurMap
->Next
== pMap
)
138 pCurMap
->Next
= pCurMap
->Next
->Next
;
141 pCurMap
= pCurMap
->Next
;
146 PAPP_MAP
FindApp(TCHAR
* szName
)
148 PAPP_MAP pMap
= s_App
;
152 if (!_tcscmp(pMap
->szName
, szName
))
162 PLABEL_CONTEXT
FindLabelContext(PSOUND_SCHEME_CONTEXT pSoundScheme
, TCHAR
* AppName
, TCHAR
* LabelName
)
164 PLABEL_CONTEXT pLabelContext
;
166 pLabelContext
= pSoundScheme
->LabelContext
;
168 while (pLabelContext
)
170 ASSERT(pLabelContext
->AppMap
);
171 ASSERT(pLabelContext
->LabelMap
);
173 if (!_tcsicmp(pLabelContext
->AppMap
->szName
, AppName
) && !_tcsicmp(pLabelContext
->LabelMap
->szName
, LabelName
))
175 return pLabelContext
;
177 pLabelContext
= pLabelContext
->Next
;
180 pLabelContext
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_CONTEXT
));
184 pLabelContext
->AppMap
= FindApp(AppName
);
185 pLabelContext
->LabelMap
= FindLabel(pLabelContext
->AppMap
, LabelName
);
186 ASSERT(pLabelContext
->AppMap
);
187 ASSERT(pLabelContext
->LabelMap
);
188 pLabelContext
->szValue
[0] = _T('\0');
189 pLabelContext
->Next
= pSoundScheme
->LabelContext
;
190 pSoundScheme
->LabelContext
= pLabelContext
;
192 return pLabelContext
;
197 LoadEventLabel(HKEY hKey
, TCHAR
* szSubKey
)
201 TCHAR szDesc
[MAX_PATH
];
202 TCHAR szData
[MAX_PATH
];
205 if (RegOpenKeyEx(hKey
,
209 &hSubKey
) != ERROR_SUCCESS
)
214 cbValue
= sizeof(szDesc
);
215 if (RegQueryValueEx(hSubKey
,
220 &cbValue
) != ERROR_SUCCESS
)
222 RegCloseKey(hSubKey
);
226 cbValue
= sizeof(szData
);
227 if (RegQueryValueEx(hSubKey
,
232 &cbValue
) != ERROR_SUCCESS
)
234 RegCloseKey(hSubKey
);
238 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
243 pMap
->szName
= _tcsdup(szSubKey
);
244 pMap
->szDesc
= _tcsdup(szDesc
);
245 pMap
->szIcon
= _tcsdup(szData
);
266 TCHAR szName
[MAX_PATH
];
270 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
271 _T("AppEvents\\EventLabels"),
274 &hSubKey
) != ERROR_SUCCESS
)
283 dwName
= _countof(szName
);
284 dwResult
= RegEnumKeyEx(hSubKey
,
293 if (dwResult
== ERROR_SUCCESS
)
295 if (LoadEventLabel(hSubKey
, szName
))
302 } while (dwResult
== ERROR_SUCCESS
);
304 RegCloseKey(hSubKey
);
305 return (dwCount
!= 0);
310 AddSoundProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szSubKey
, BOOL SetDefault
)
313 TCHAR szValue
[MAX_PATH
];
314 DWORD cbValue
, dwResult
;
316 PSOUND_SCHEME_CONTEXT pScheme
;
318 if (RegOpenKeyEx(hKey
,
322 &hSubKey
) != ERROR_SUCCESS
)
327 cbValue
= sizeof(szValue
);
328 dwResult
= RegQueryValueEx(hSubKey
,
334 RegCloseKey(hSubKey
);
336 if (dwResult
!= ERROR_SUCCESS
)
339 /* Try to add the new profile */
340 lResult
= ComboBox_AddString(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), szValue
);
341 if (lResult
== CB_ERR
)
344 /* Allocate the profile scheme buffer */
345 pScheme
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SOUND_SCHEME_CONTEXT
));
348 /* We failed to allocate the buffer, no need to keep a dangling string in the combobox */
349 ComboBox_DeleteString(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), lResult
);
353 StringCchCopy(pScheme
->szDesc
, MAX_PATH
, szValue
);
354 StringCchCopy(pScheme
->szName
, MAX_PATH
, szSubKey
);
356 /* Associate the value with the item in the combobox */
357 ComboBox_SetItemData(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), lResult
, pScheme
);
359 /* Optionally, select the profile */
362 ComboBox_SetCurSel(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), lResult
);
370 EnumerateSoundProfiles(HWND hwndDlg
, HKEY hKey
)
373 DWORD dwName
, dwCurKey
, dwResult
, dwNumSchemes
;
375 TCHAR szName
[MAX_PATH
];
377 cbDefault
= sizeof(szDefault
);
378 if (RegQueryValueEx(hKey
,
383 &cbDefault
) != ERROR_SUCCESS
)
390 if (RegOpenKeyEx(hKey
,
394 &hSubKey
) != ERROR_SUCCESS
)
403 dwName
= _countof(szName
);
404 dwResult
= RegEnumKeyEx(hSubKey
,
413 if (dwResult
== ERROR_SUCCESS
)
415 if (AddSoundProfile(hwndDlg
, hSubKey
, szName
, (!_tcsicmp(szName
, szDefault
))))
422 } while (dwResult
== ERROR_SUCCESS
);
424 RegCloseKey(hSubKey
);
429 PSOUND_SCHEME_CONTEXT
FindSoundProfile(HWND hwndDlg
, TCHAR
* szName
)
431 LRESULT lCount
, lIndex
, lResult
;
432 PSOUND_SCHEME_CONTEXT pScheme
;
434 lCount
= ComboBox_GetCount(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
435 if (lCount
== CB_ERR
)
440 for(lIndex
= 0; lIndex
< lCount
; lIndex
++)
442 lResult
= ComboBox_GetItemData(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), lIndex
);
443 if (lResult
== CB_ERR
)
448 pScheme
= (PSOUND_SCHEME_CONTEXT
)lResult
;
449 if (!_tcsicmp(pScheme
->szName
, szName
))
459 ImportSoundLabel(HWND hwndDlg
, HKEY hKey
, TCHAR
* szProfile
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP AppMap
, PLABEL_MAP LabelMap
)
462 TCHAR szValue
[MAX_PATH
];
463 TCHAR szBuffer
[MAX_PATH
];
464 DWORD cbValue
, cchLength
;
465 PSOUND_SCHEME_CONTEXT pScheme
;
466 PLABEL_CONTEXT pLabelContext
;
467 BOOL bCurrentProfile
, bActiveProfile
;
469 //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
471 bCurrentProfile
= !_tcsicmp(szProfile
, _T(".Current"));
472 bActiveProfile
= !_tcsicmp(szProfile
, szDefault
);
474 if (RegOpenKeyEx(hKey
,
478 &hSubKey
) != ERROR_SUCCESS
)
483 cbValue
= sizeof(szValue
);
484 if (RegQueryValueEx(hSubKey
,
489 &cbValue
) != ERROR_SUCCESS
)
495 pScheme
= FindSoundProfile(hwndDlg
, szDefault
);
497 pScheme
= FindSoundProfile(hwndDlg
, szProfile
);
501 //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
504 pLabelContext
= FindLabelContext(pScheme
, AppMap
->szName
, LabelMap
->szName
);
506 cchLength
= ExpandEnvironmentStrings(szValue
, szBuffer
, _countof(szBuffer
));
507 if (cchLength
== 0 || cchLength
> _countof(szBuffer
))
514 _tcscpy(pLabelContext
->szValue
, szBuffer
);
515 else if (!bActiveProfile
)
516 _tcscpy(pLabelContext
->szValue
, szBuffer
);
523 ImportSoundEntry(HWND hwndDlg
, HKEY hKey
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP pAppMap
)
530 TCHAR szProfile
[MAX_PATH
];
533 if (RegOpenKeyEx(hKey
,
537 &hSubKey
) != ERROR_SUCCESS
)
541 pLabel
= FindLabel(pAppMap
, szLabelName
);
546 pLabel
->AppMap
= pAppMap
;
547 pLabel
->Next
= pAppMap
->LabelMap
;
548 pAppMap
->LabelMap
= pLabel
;
554 dwProfile
= _countof(szProfile
);
555 dwResult
= RegEnumKeyEx(hSubKey
,
564 if (dwResult
== ERROR_SUCCESS
)
566 if (ImportSoundLabel(hwndDlg
, hSubKey
, szProfile
, szLabelName
, szAppName
, pAppMap
, pLabel
))
573 } while (dwResult
== ERROR_SUCCESS
);
575 RegCloseKey(hSubKey
);
577 return dwNumProfiles
;
582 ImportAppProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szAppName
)
585 TCHAR szDefault
[MAX_PATH
];
591 TCHAR szName
[MAX_PATH
];
592 TCHAR szIcon
[MAX_PATH
];
595 //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
597 AppMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(APP_MAP
));
601 if (RegOpenKeyEx(hKey
,
605 &hSubKey
) != ERROR_SUCCESS
)
607 HeapFree(GetProcessHeap(), 0, AppMap
);
611 cbValue
= sizeof(szDefault
);
612 if (RegQueryValueEx(hSubKey
,
617 &cbValue
) != ERROR_SUCCESS
)
619 RegCloseKey(hSubKey
);
620 HeapFree(GetProcessHeap(), 0, AppMap
);
624 cbValue
= sizeof(szIcon
);
625 if (RegQueryValueEx(hSubKey
,
630 &cbValue
) != ERROR_SUCCESS
)
632 szIcon
[0] = _T('\0');
635 /* initialize app map */
636 _tcscpy(AppMap
->szName
, szAppName
);
637 _tcscpy(AppMap
->szDesc
, szDefault
);
638 _tcscpy(AppMap
->szIcon
, szIcon
);
640 AppMap
->Next
= s_App
;
648 dwName
= _countof(szName
);
649 dwResult
= RegEnumKeyEx(hSubKey
,
657 if (dwResult
== ERROR_SUCCESS
)
659 if (ImportSoundEntry(hwndDlg
, hSubKey
, szName
, szAppName
, AppMap
))
665 } while (dwResult
== ERROR_SUCCESS
);
667 RegCloseKey(hSubKey
);
673 ImportSoundProfiles(HWND hwndDlg
, HKEY hKey
)
678 TCHAR szName
[MAX_PATH
];
681 if (RegOpenKeyEx(hKey
,
685 &hSubKey
) != ERROR_SUCCESS
)
694 dwResult
= RegEnumKey(hSubKey
,
699 if (dwResult
== ERROR_SUCCESS
)
701 if (ImportAppProfile(hwndDlg
, hSubKey
, szName
))
707 } while (dwResult
== ERROR_SUCCESS
);
709 RegCloseKey(hSubKey
);
711 return (dwNumApps
!= 0);
716 LoadSoundProfiles(HWND hwndDlg
)
721 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
722 _T("AppEvents\\Schemes"),
725 &hSubKey
) != ERROR_SUCCESS
)
730 dwNumSchemes
= EnumerateSoundProfiles(hwndDlg
, hSubKey
);
735 //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
736 ImportSoundProfiles(hwndDlg
, hSubKey
);
739 RegCloseKey(hSubKey
);
745 LoadSoundFiles(HWND hwndDlg
)
748 WCHAR szPath
[MAX_PATH
];
750 WIN32_FIND_DATAW FileData
;
755 /* Add no sound listview item */
756 if (LoadString(hApplet
, IDS_NO_SOUND
, szList
, _countof(szList
)))
758 szList
[_countof(szList
) - 1] = TEXT('\0');
759 ComboBox_AddString(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), szList
);
762 /* Load sound files */
763 length
= GetWindowsDirectoryW(szPath
, MAX_PATH
);
764 if (length
== 0 || length
>= MAX_PATH
- 9)
768 if (szPath
[length
-1] != L
'\\')
770 szPath
[length
] = L
'\\';
773 wcscpy(&szPath
[length
], L
"media\\*");
776 hFile
= FindFirstFileW(szPath
, &FileData
);
777 if (hFile
== INVALID_HANDLE_VALUE
)
784 if (FileData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
787 ptr
= wcsrchr(FileData
.cFileName
, L
'\\');
794 ptr
= FileData
.cFileName
;
796 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
797 if (lResult
!= CB_ERR
)
799 wcscpy(&szPath
[length
-1], FileData
.cFileName
);
800 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(szPath
));
802 } while (FindNextFileW(hFile
, &FileData
) != 0);
810 ShowSoundScheme(HWND hwndDlg
)
813 PSOUND_SCHEME_CONTEXT pScheme
;
817 HWND hDlgCtrl
, hList
;
820 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
821 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
823 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
824 if (lIndex
== CB_ERR
)
829 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
830 if (lIndex
== CB_ERR
)
834 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
836 _tcscpy(szDefault
, pScheme
->szName
);
838 /* add column for app */
839 GetClientRect(hList
, &rect
);
840 ZeroMemory(&dummy
, sizeof(dummy
));
841 dummy
.mask
= LVCF_WIDTH
;
843 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
844 (void)ListView_InsertColumn(hList
, 0, &dummy
);
850 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
853 ZeroMemory(&listItem
, sizeof(listItem
));
854 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
855 listItem
.pszText
= pLabelMap
->szDesc
;
856 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
857 listItem
.iItem
= ItemIndex
;
858 listItem
.iImage
= -1;
859 (void)ListView_InsertItem(hList
, &listItem
);
862 pLabelMap
= pLabelMap
->Next
;
864 pAppMap
= pAppMap
->Next
;
871 ApplyChanges(HWND hwndDlg
)
875 PSOUND_SCHEME_CONTEXT pScheme
;
877 PLABEL_CONTEXT pLabelContext
;
880 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
882 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
883 if (lIndex
== CB_ERR
)
888 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
889 if (lIndex
== CB_ERR
)
893 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
895 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
896 _T("AppEvents\\Schemes"),
899 &hKey
) != ERROR_SUCCESS
)
904 RegSetValueEx(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pScheme
->szName
, (_tcslen(pScheme
->szName
) +1) * sizeof(TCHAR
));
907 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
908 _T("AppEvents\\Schemes\\Apps"),
911 &hKey
) != ERROR_SUCCESS
)
916 pLabelContext
= pScheme
->LabelContext
;
918 while (pLabelContext
)
920 _stprintf(Buffer
, _T("%s\\%s\\.Current"), pLabelContext
->AppMap
->szName
, pLabelContext
->LabelMap
->szName
);
922 if (RegOpenKeyEx(hKey
, Buffer
, 0, KEY_WRITE
, &hSubKey
) == ERROR_SUCCESS
)
924 RegSetValueEx(hSubKey
, NULL
, 0, REG_EXPAND_SZ
, (LPBYTE
)pLabelContext
->szValue
, (_tcslen(pLabelContext
->szValue
) +1) * sizeof(TCHAR
));
925 RegCloseKey(hSubKey
);
928 pLabelContext
= pLabelContext
->Next
;
932 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, (LONG
)PSNRET_NOERROR
);
937 /* Sounds property page dialog callback */
940 SoundsDlgProc(HWND hwndDlg
,
946 WCHAR filename
[MAX_PATH
];
947 WCHAR szFilter
[256], szTitle
[256];
955 UINT NumWavOut
= waveOutGetNumDevs();
957 SendMessage(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
),
958 BM_SETIMAGE
,(WPARAM
)IMAGE_ICON
,
959 (LPARAM
)(HANDLE
)LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_PLAY_ICON
)));
962 LoadSoundProfiles(hwndDlg
);
963 LoadSoundFiles(hwndDlg
);
964 ShowSoundScheme(hwndDlg
);
968 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), FALSE
);
969 EnableWindow(GetDlgItem(hwndDlg
, IDC_SAVEAS_BTN
), FALSE
);
970 EnableWindow(GetDlgItem(hwndDlg
, IDC_DELETE_BTN
), FALSE
);
971 EnableWindow(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), FALSE
);
974 if (wParam
== (WPARAM
)GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
))
976 SetFocus(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
981 switch (LOWORD(wParam
))
983 case IDC_BROWSE_SOUND
:
985 ZeroMemory(&ofn
, sizeof(ofn
));
986 ofn
.lStructSize
= sizeof(ofn
);
987 ofn
.hwndOwner
= hwndDlg
;
988 ofn
.lpstrFile
= filename
;
989 ofn
.lpstrFile
[0] = L
'\0';
990 ofn
.nMaxFile
= _countof(filename
);
991 LoadStringW(hApplet
, IDS_WAVE_FILES_FILTER
, szFilter
, _countof(szFilter
));
992 ofn
.lpstrFilter
= MakeFilter(szFilter
);
993 ofn
.nFilterIndex
= 0;
994 LoadStringW(hApplet
, IDS_BROWSE_FOR_SOUND
, szTitle
, _countof(szTitle
));
995 ofn
.lpstrTitle
= szTitle
;
996 ofn
.lpstrInitialDir
= NULL
;
997 ofn
.Flags
= OFN_FILEMUSTEXIST
| OFN_HIDEREADONLY
;
999 if (GetOpenFileNameW(&ofn
) != FALSE
)
1001 // FIXME search if list already contains that sound
1003 // extract file name
1004 pFileName
= wcsrchr(filename
, L
'\\');
1005 ASSERT(pFileName
!= NULL
);
1009 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)pFileName
);
1010 if (lResult
!= CB_ERR
)
1012 // add path and select item
1013 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(filename
));
1014 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
1019 case IDC_PLAY_SOUND
:
1022 lIndex
= ComboBox_GetCurSel(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
));
1023 if (lIndex
== CB_ERR
)
1028 lIndex
= ComboBox_GetItemData(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), lIndex
);
1029 if (lIndex
!= CB_ERR
)
1031 PlaySound((TCHAR
*)lIndex
, NULL
, SND_FILENAME
);
1035 case IDC_SOUND_SCHEME
:
1037 if (HIWORD(wParam
) == CBN_SELENDOK
)
1039 (void)ListView_DeleteAllItems(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
1040 ShowSoundScheme(hwndDlg
);
1041 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), FALSE
);
1042 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), FALSE
);
1043 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1044 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), FALSE
);
1045 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1049 case IDC_SOUND_LIST
:
1051 if (HIWORD(wParam
) == CBN_SELENDOK
)
1053 PLABEL_CONTEXT pLabelContext
;
1057 SelCount
= ListView_GetSelectionMark(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
1062 lIndex
= ComboBox_GetCurSel(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
));
1063 if (lIndex
== CB_ERR
)
1067 ZeroMemory(&item
, sizeof(item
));
1068 item
.mask
= LVIF_PARAM
;
1069 item
.iItem
= SelCount
;
1070 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1073 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1075 lResult
= ComboBox_GetItemData(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), lIndex
);
1076 if (lResult
== CB_ERR
|| lResult
== 0)
1078 if (lIndex
!= pLabelContext
->szValue
[0])
1079 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1081 pLabelContext
->szValue
[0] = L
'\0';
1085 if (_tcsicmp(pLabelContext
->szValue
, (TCHAR
*)lResult
) || (lIndex
!= pLabelContext
->szValue
[0]))
1087 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1089 /// Should store in current member
1091 _tcscpy(pLabelContext
->szValue
, (TCHAR
*)lResult
);
1093 if (_tcslen((TCHAR
*)lResult
) && lIndex
!= 0)
1095 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1099 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1111 PLABEL_CONTEXT pLabelContext
;
1114 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1120 ApplyChanges(hwndDlg
);
1123 case LVN_ITEMCHANGED
:
1125 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1127 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1131 ZeroMemory(&item
, sizeof(item
));
1132 item
.mask
= LVIF_PARAM
;
1133 item
.iItem
= nm
->iItem
;
1135 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1137 LRESULT lCount
, lIndex
, lResult
;
1138 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1143 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1144 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1145 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1146 if (_tcslen(pLabelContext
->szValue
) == 0)
1148 lIndex
= ComboBox_SetCurSel(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), 0);
1149 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1153 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1154 lCount
= ComboBox_GetCount(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
));
1155 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1157 lResult
= ComboBox_GetItemData(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), lIndex
);
1158 if (lResult
== CB_ERR
|| lResult
== 0)
1161 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1163 ComboBox_SetCurSel(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), lIndex
);
1167 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1174 ptr
= pLabelContext
->szValue
;
1176 lIndex
= ComboBox_AddString(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), ptr
);
1177 if (lIndex
!= CB_ERR
)
1179 ComboBox_SetItemData(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), lIndex
, _tcsdup(pLabelContext
->szValue
));
1180 ComboBox_SetCurSel(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), lIndex
);