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>
20 typedef struct __LABEL_MAP__
25 struct __APP_MAP__
* AppMap
;
26 struct __LABEL_MAP__
* Next
;
27 } LABEL_MAP
, *PLABEL_MAP
;
29 typedef struct __APP_MAP__
31 TCHAR szName
[MAX_PATH
];
32 TCHAR szDesc
[MAX_PATH
];
33 TCHAR szIcon
[MAX_PATH
];
35 struct __APP_MAP__
*Next
;
39 typedef struct __LABEL_CONTEXT__
43 TCHAR szValue
[MAX_PATH
];
44 struct __LABEL_CONTEXT__
*Next
;
45 } LABEL_CONTEXT
, *PLABEL_CONTEXT
;
47 typedef struct __SOUND_SCHEME_CONTEXT__
49 TCHAR szName
[MAX_PATH
];
50 TCHAR szDesc
[MAX_PATH
];
51 PLABEL_CONTEXT LabelContext
;
52 } SOUND_SCHEME_CONTEXT
, *PSOUND_SCHEME_CONTEXT
;
54 static PLABEL_MAP s_Map
= NULL
;
55 static PAPP_MAP s_App
= NULL
;
57 TCHAR szDefault
[MAX_PATH
];
60 PLABEL_MAP
FindLabel(PAPP_MAP pAppMap
, TCHAR
* szName
)
62 PLABEL_MAP pMap
= s_Map
;
68 if (!_tcscmp(pMap
->szName
, szName
))
74 pMap
= pAppMap
->LabelMap
;
80 if (!_tcscmp(pMap
->szName
, szName
))
86 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
90 pMap
->szName
= pMap
->szDesc
= _tcsdup(szName
);
93 HeapFree(GetProcessHeap(), 0, pMap
);
97 pMap
->AppMap
= pAppMap
;
105 VOID
RemoveLabel(PLABEL_MAP pMap
)
107 PLABEL_MAP pCurMap
= s_Map
;
117 if (pCurMap
->Next
== pMap
)
119 pCurMap
->Next
= pCurMap
->Next
->Next
;
122 pCurMap
= pCurMap
->Next
;
127 PAPP_MAP
FindApp(TCHAR
* szName
)
129 PAPP_MAP pMap
= s_App
;
133 if (!_tcscmp(pMap
->szName
, szName
))
143 PLABEL_CONTEXT
FindLabelContext(PSOUND_SCHEME_CONTEXT pSoundScheme
, TCHAR
* AppName
, TCHAR
* LabelName
)
145 PLABEL_CONTEXT pLabelContext
;
147 pLabelContext
= pSoundScheme
->LabelContext
;
149 while (pLabelContext
)
151 ASSERT(pLabelContext
->AppMap
);
152 ASSERT(pLabelContext
->LabelMap
);
154 if (!_tcsicmp(pLabelContext
->AppMap
->szName
, AppName
) && !_tcsicmp(pLabelContext
->LabelMap
->szName
, LabelName
))
156 return pLabelContext
;
158 pLabelContext
= pLabelContext
->Next
;
161 pLabelContext
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_CONTEXT
));
165 pLabelContext
->AppMap
= FindApp(AppName
);
166 pLabelContext
->LabelMap
= FindLabel(pLabelContext
->AppMap
, LabelName
);
167 ASSERT(pLabelContext
->AppMap
);
168 ASSERT(pLabelContext
->LabelMap
);
169 pLabelContext
->szValue
[0] = _T('\0');
170 pLabelContext
->Next
= pSoundScheme
->LabelContext
;
171 pSoundScheme
->LabelContext
= pLabelContext
;
173 return pLabelContext
;
178 LoadEventLabel(HKEY hKey
, TCHAR
* szSubKey
)
182 TCHAR szDesc
[MAX_PATH
];
183 TCHAR szData
[MAX_PATH
];
186 if (RegOpenKeyEx(hKey
,
190 &hSubKey
) != ERROR_SUCCESS
)
195 cbValue
= sizeof(szDesc
);
196 if (RegQueryValueEx(hSubKey
,
201 &cbValue
) != ERROR_SUCCESS
)
203 RegCloseKey(hSubKey
);
207 cbValue
= sizeof(szData
);
208 if (RegQueryValueEx(hSubKey
,
213 &cbValue
) != ERROR_SUCCESS
)
215 RegCloseKey(hSubKey
);
219 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
224 pMap
->szName
= _tcsdup(szSubKey
);
225 pMap
->szDesc
= _tcsdup(szDesc
);
226 pMap
->szIcon
= _tcsdup(szData
);
247 TCHAR szName
[MAX_PATH
];
251 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
252 _T("AppEvents\\EventLabels"),
255 &hSubKey
) != ERROR_SUCCESS
)
264 dwName
= _countof(szName
);
265 dwResult
= RegEnumKeyEx(hSubKey
,
274 if (dwResult
== ERROR_SUCCESS
)
276 if (LoadEventLabel(hSubKey
, szName
))
283 } while (dwResult
== ERROR_SUCCESS
);
285 RegCloseKey(hSubKey
);
286 return (dwCount
!= 0);
291 AddSoundProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szSubKey
, BOOL SetDefault
)
294 TCHAR szValue
[MAX_PATH
];
295 DWORD cbValue
, dwResult
;
297 PSOUND_SCHEME_CONTEXT pScheme
;
299 if (RegOpenKeyEx(hKey
,
303 &hSubKey
) != ERROR_SUCCESS
)
308 cbValue
= sizeof(szValue
);
309 dwResult
= RegQueryValueEx(hSubKey
,
315 RegCloseKey(hSubKey
);
317 if (dwResult
!= ERROR_SUCCESS
)
320 /* Try to add the new profile */
321 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
322 if (lResult
== CB_ERR
)
325 /* Allocate the profile scheme buffer */
326 pScheme
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SOUND_SCHEME_CONTEXT
));
329 /* We failed to allocate the buffer, no need to keep a dangling string in the combobox */
330 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_DELETESTRING
, (WPARAM
)lResult
, (LPARAM
)0);
334 StringCchCopy(pScheme
->szDesc
, MAX_PATH
, szValue
);
335 StringCchCopy(pScheme
->szName
, MAX_PATH
, szSubKey
);
337 /* Associate the value with the item in the combobox */
338 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pScheme
);
340 /* Optionally, select the profile */
342 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
349 EnumerateSoundProfiles(HWND hwndDlg
, HKEY hKey
)
352 DWORD dwName
, dwCurKey
, dwResult
, dwNumSchemes
;
354 TCHAR szName
[MAX_PATH
];
356 cbDefault
= sizeof(szDefault
);
357 if (RegQueryValueEx(hKey
,
362 &cbDefault
) != ERROR_SUCCESS
)
369 if (RegOpenKeyEx(hKey
,
373 &hSubKey
) != ERROR_SUCCESS
)
382 dwName
= _countof(szName
);
383 dwResult
= RegEnumKeyEx(hSubKey
,
392 if (dwResult
== ERROR_SUCCESS
)
394 if (AddSoundProfile(hwndDlg
, hSubKey
, szName
, (!_tcsicmp(szName
, szDefault
))))
401 } while (dwResult
== ERROR_SUCCESS
);
403 RegCloseKey(hSubKey
);
408 PSOUND_SCHEME_CONTEXT
FindSoundProfile(HWND hwndDlg
, TCHAR
* szName
)
410 LRESULT lCount
, lIndex
, lResult
;
411 PSOUND_SCHEME_CONTEXT pScheme
;
413 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
414 if (lCount
== CB_ERR
)
419 for(lIndex
= 0; lIndex
< lCount
; lIndex
++)
421 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
422 if (lResult
== CB_ERR
)
427 pScheme
= (PSOUND_SCHEME_CONTEXT
)lResult
;
428 if (!_tcsicmp(pScheme
->szName
, szName
))
438 ImportSoundLabel(HWND hwndDlg
, HKEY hKey
, TCHAR
* szProfile
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP AppMap
, PLABEL_MAP LabelMap
)
441 TCHAR szValue
[MAX_PATH
];
442 TCHAR szBuffer
[MAX_PATH
];
443 DWORD cbValue
, cchLength
;
444 PSOUND_SCHEME_CONTEXT pScheme
;
445 PLABEL_CONTEXT pLabelContext
;
446 BOOL bCurrentProfile
, bActiveProfile
;
448 //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
450 bCurrentProfile
= !_tcsicmp(szProfile
, _T(".Current"));
451 bActiveProfile
= !_tcsicmp(szProfile
, szDefault
);
453 if (RegOpenKeyEx(hKey
,
457 &hSubKey
) != ERROR_SUCCESS
)
462 cbValue
= sizeof(szValue
);
463 if (RegQueryValueEx(hSubKey
,
468 &cbValue
) != ERROR_SUCCESS
)
474 pScheme
= FindSoundProfile(hwndDlg
, szDefault
);
476 pScheme
= FindSoundProfile(hwndDlg
, szProfile
);
480 //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
483 pLabelContext
= FindLabelContext(pScheme
, AppMap
->szName
, LabelMap
->szName
);
485 cchLength
= ExpandEnvironmentStrings(szValue
, szBuffer
, _countof(szBuffer
));
486 if (cchLength
== 0 || cchLength
> _countof(szBuffer
))
493 _tcscpy(pLabelContext
->szValue
, szBuffer
);
494 else if (!bActiveProfile
)
495 _tcscpy(pLabelContext
->szValue
, szBuffer
);
502 ImportSoundEntry(HWND hwndDlg
, HKEY hKey
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP pAppMap
)
509 TCHAR szProfile
[MAX_PATH
];
512 if (RegOpenKeyEx(hKey
,
516 &hSubKey
) != ERROR_SUCCESS
)
520 pLabel
= FindLabel(pAppMap
, szLabelName
);
525 pLabel
->AppMap
= pAppMap
;
526 pLabel
->Next
= pAppMap
->LabelMap
;
527 pAppMap
->LabelMap
= pLabel
;
533 dwProfile
= _countof(szProfile
);
534 dwResult
= RegEnumKeyEx(hSubKey
,
543 if (dwResult
== ERROR_SUCCESS
)
545 if (ImportSoundLabel(hwndDlg
, hSubKey
, szProfile
, szLabelName
, szAppName
, pAppMap
, pLabel
))
552 } while (dwResult
== ERROR_SUCCESS
);
554 RegCloseKey(hSubKey
);
556 return dwNumProfiles
;
561 ImportAppProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szAppName
)
564 TCHAR szDefault
[MAX_PATH
];
570 TCHAR szName
[MAX_PATH
];
571 TCHAR szIcon
[MAX_PATH
];
574 //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
576 AppMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(APP_MAP
));
580 if (RegOpenKeyEx(hKey
,
584 &hSubKey
) != ERROR_SUCCESS
)
586 HeapFree(GetProcessHeap(), 0, AppMap
);
590 cbValue
= sizeof(szDefault
);
591 if (RegQueryValueEx(hSubKey
,
596 &cbValue
) != ERROR_SUCCESS
)
598 RegCloseKey(hSubKey
);
599 HeapFree(GetProcessHeap(), 0, AppMap
);
603 cbValue
= sizeof(szIcon
);
604 if (RegQueryValueEx(hSubKey
,
609 &cbValue
) != ERROR_SUCCESS
)
611 szIcon
[0] = _T('\0');
614 /* initialize app map */
615 _tcscpy(AppMap
->szName
, szAppName
);
616 _tcscpy(AppMap
->szDesc
, szDefault
);
617 _tcscpy(AppMap
->szIcon
, szIcon
);
619 AppMap
->Next
= s_App
;
627 dwName
= _countof(szName
);
628 dwResult
= RegEnumKeyEx(hSubKey
,
636 if (dwResult
== ERROR_SUCCESS
)
638 if (ImportSoundEntry(hwndDlg
, hSubKey
, szName
, szAppName
, AppMap
))
644 } while (dwResult
== ERROR_SUCCESS
);
646 RegCloseKey(hSubKey
);
652 ImportSoundProfiles(HWND hwndDlg
, HKEY hKey
)
657 TCHAR szName
[MAX_PATH
];
660 if (RegOpenKeyEx(hKey
,
664 &hSubKey
) != ERROR_SUCCESS
)
673 dwResult
= RegEnumKey(hSubKey
,
678 if (dwResult
== ERROR_SUCCESS
)
680 if (ImportAppProfile(hwndDlg
, hSubKey
, szName
))
686 } while (dwResult
== ERROR_SUCCESS
);
688 RegCloseKey(hSubKey
);
690 return (dwNumApps
!= 0);
695 LoadSoundProfiles(HWND hwndDlg
)
700 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
701 _T("AppEvents\\Schemes"),
704 &hSubKey
) != ERROR_SUCCESS
)
709 dwNumSchemes
= EnumerateSoundProfiles(hwndDlg
, hSubKey
);
714 //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
715 ImportSoundProfiles(hwndDlg
, hSubKey
);
718 RegCloseKey(hSubKey
);
724 LoadSoundFiles(HWND hwndDlg
)
726 WCHAR szPath
[MAX_PATH
];
728 WIN32_FIND_DATAW FileData
;
733 /* Add no sound listview item */
734 if (LoadString(hApplet
, IDS_NO_SOUND
, szPath
, _countof(szPath
)))
736 szPath
[_countof(szPath
)-1] = L
'\0';
737 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szPath
);
740 /* Load sound files */
741 length
= GetWindowsDirectoryW(szPath
, MAX_PATH
);
742 if (length
== 0 || length
>= MAX_PATH
- 9)
746 if (szPath
[length
-1] != L
'\\')
748 szPath
[length
] = L
'\\';
751 wcscpy(&szPath
[length
], L
"media\\*");
754 hFile
= FindFirstFileW(szPath
, &FileData
);
755 if (hFile
== INVALID_HANDLE_VALUE
)
762 if (FileData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
765 ptr
= wcsrchr(FileData
.cFileName
, L
'\\');
772 ptr
= FileData
.cFileName
;
774 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
775 if (lResult
!= CB_ERR
)
777 wcscpy(&szPath
[length
-1], FileData
.cFileName
);
778 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(szPath
));
780 } while (FindNextFileW(hFile
, &FileData
) != 0);
788 ShowSoundScheme(HWND hwndDlg
)
791 PSOUND_SCHEME_CONTEXT pScheme
;
795 HWND hDlgCtrl
, hList
;
798 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
799 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
801 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
802 if (lIndex
== CB_ERR
)
807 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
808 if (lIndex
== CB_ERR
)
812 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
814 _tcscpy(szDefault
, pScheme
->szName
);
816 /* add column for app */
817 GetClientRect(hList
, &rect
);
818 ZeroMemory(&dummy
, sizeof(dummy
));
819 dummy
.mask
= LVCF_WIDTH
;
821 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
822 (void)ListView_InsertColumn(hList
, 0, &dummy
);
828 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
831 ZeroMemory(&listItem
, sizeof(listItem
));
832 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
833 listItem
.pszText
= pLabelMap
->szDesc
;
834 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
835 listItem
.iItem
= ItemIndex
;
836 listItem
.iImage
= -1;
837 (void)ListView_InsertItem(hList
, &listItem
);
840 pLabelMap
= pLabelMap
->Next
;
842 pAppMap
= pAppMap
->Next
;
849 ApplyChanges(HWND hwndDlg
)
853 PSOUND_SCHEME_CONTEXT pScheme
;
855 PLABEL_CONTEXT pLabelContext
;
858 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
860 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
861 if (lIndex
== CB_ERR
)
866 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
867 if (lIndex
== CB_ERR
)
871 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
873 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
874 _T("AppEvents\\Schemes"),
877 &hKey
) != ERROR_SUCCESS
)
882 RegSetValueEx(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pScheme
->szName
, (_tcslen(pScheme
->szName
) +1) * sizeof(TCHAR
));
885 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
886 _T("AppEvents\\Schemes\\Apps"),
889 &hKey
) != ERROR_SUCCESS
)
894 pLabelContext
= pScheme
->LabelContext
;
896 while (pLabelContext
)
898 _stprintf(Buffer
, _T("%s\\%s\\.Current"), pLabelContext
->AppMap
->szName
, pLabelContext
->LabelMap
->szName
);
900 if (RegOpenKeyEx(hKey
, Buffer
, 0, KEY_WRITE
, &hSubKey
) == ERROR_SUCCESS
)
902 RegSetValueEx(hSubKey
, NULL
, 0, REG_EXPAND_SZ
, (LPBYTE
)pLabelContext
->szValue
, (_tcslen(pLabelContext
->szValue
) +1) * sizeof(TCHAR
));
903 RegCloseKey(hSubKey
);
906 pLabelContext
= pLabelContext
->Next
;
910 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, (LONG
)PSNRET_NOERROR
);
915 /* Sounds property page dialog callback */
918 SoundsDlgProc(HWND hwndDlg
,
924 WCHAR filename
[MAX_PATH
];
932 UINT NumWavOut
= waveOutGetNumDevs();
934 SendMessage(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
),
935 BM_SETIMAGE
,(WPARAM
)IMAGE_ICON
,
936 (LPARAM
)(HANDLE
)LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_PLAY_ICON
)));
939 LoadSoundProfiles(hwndDlg
);
940 LoadSoundFiles(hwndDlg
);
941 ShowSoundScheme(hwndDlg
);
945 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), FALSE
);
946 EnableWindow(GetDlgItem(hwndDlg
, IDC_SAVEAS_BTN
), FALSE
);
947 EnableWindow(GetDlgItem(hwndDlg
, IDC_DELETE_BTN
), FALSE
);
948 EnableWindow(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), FALSE
);
951 if (wParam
== (WPARAM
)GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
))
953 SetFocus(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
958 switch (LOWORD(wParam
))
960 case IDC_BROWSE_SOUND
:
962 ZeroMemory(&ofn
, sizeof(ofn
));
963 ofn
.lStructSize
= sizeof(ofn
);
964 ofn
.hwndOwner
= hwndDlg
;
965 ofn
.lpstrFile
= filename
;
966 ofn
.lpstrFile
[0] = L
'\0';
967 ofn
.nMaxFile
= MAX_PATH
;
968 ofn
.lpstrFilter
= L
"Wave Files (*.wav)\0*.wav\0"; //FIXME non-nls
969 ofn
.nFilterIndex
= 0;
970 ofn
.lpstrFileTitle
= L
"Search for new sounds"; //FIXME non-nls
971 ofn
.nMaxFileTitle
= wcslen(ofn
.lpstrFileTitle
);
972 ofn
.lpstrInitialDir
= NULL
;
973 ofn
.Flags
= OFN_FILEMUSTEXIST
| OFN_HIDEREADONLY
;
975 if (GetOpenFileNameW(&ofn
) == TRUE
)
977 // FIXME search if list already contains that sound
980 pFileName
= wcsrchr(filename
, L
'\\');
981 ASSERT(pFileName
!= NULL
);
985 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)pFileName
);
986 if (lResult
!= CB_ERR
)
988 // add path and select item
989 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(filename
));
990 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
998 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
999 if (lIndex
== CB_ERR
)
1004 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1005 if (lIndex
!= CB_ERR
)
1007 PlaySound((TCHAR
*)lIndex
, NULL
, SND_FILENAME
);
1011 case IDC_SOUND_SCHEME
:
1013 if (HIWORD(wParam
) == CBN_SELENDOK
)
1015 (void)ListView_DeleteAllItems(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
1016 ShowSoundScheme(hwndDlg
);
1017 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), FALSE
);
1018 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), FALSE
);
1019 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1020 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), FALSE
);
1021 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1025 case IDC_SOUND_LIST
:
1027 if (HIWORD(wParam
) == CBN_SELENDOK
)
1029 PLABEL_CONTEXT pLabelContext
;
1033 SelCount
= ListView_GetSelectionMark(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
1038 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1039 if (lIndex
== CB_ERR
)
1043 ZeroMemory(&item
, sizeof(item
));
1044 item
.mask
= LVIF_PARAM
;
1045 item
.iItem
= SelCount
;
1046 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1049 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1051 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1052 if (lResult
== CB_ERR
|| lResult
== 0)
1054 if (lIndex
!= pLabelContext
->szValue
[0])
1055 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1057 pLabelContext
->szValue
[0] = L
'\0';
1061 if (_tcsicmp(pLabelContext
->szValue
, (TCHAR
*)lResult
) || (lIndex
!= pLabelContext
->szValue
[0]))
1063 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1065 /// Should store in current member
1067 _tcscpy(pLabelContext
->szValue
, (TCHAR
*)lResult
);
1069 if (_tcslen((TCHAR
*)lResult
) && lIndex
!= 0)
1071 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1075 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1087 PLABEL_CONTEXT pLabelContext
;
1090 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1096 ApplyChanges(hwndDlg
);
1099 case LVN_ITEMCHANGED
:
1101 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1103 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1107 ZeroMemory(&item
, sizeof(item
));
1108 item
.mask
= LVIF_PARAM
;
1109 item
.iItem
= nm
->iItem
;
1111 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1113 LRESULT lCount
, lIndex
, lResult
;
1114 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1119 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1120 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1121 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1122 if (_tcslen(pLabelContext
->szValue
) == 0)
1124 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1125 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1129 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1130 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
1131 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1133 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1134 if (lResult
== CB_ERR
|| lResult
== 0)
1137 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1139 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);
1143 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1150 ptr
= pLabelContext
->szValue
;
1152 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
1153 if (lIndex
!= CB_ERR
)
1155 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)_tcsdup(pLabelContext
->szValue
));
1156 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);