2 * PROJECT: ReactOS Multimedia Control Panel
3 * FILE: dll/cpl/mmsys/mmsys.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>
17 typedef struct __LABEL_MAP__
22 struct __APP_MAP__
* AppMap
;
23 struct __LABEL_MAP__
* Next
;
24 } LABEL_MAP
, *PLABEL_MAP
;
26 typedef struct __APP_MAP__
28 TCHAR szName
[MAX_PATH
];
29 TCHAR szDesc
[MAX_PATH
];
30 TCHAR szIcon
[MAX_PATH
];
32 struct __APP_MAP__
*Next
;
36 typedef struct __LABEL_CONTEXT__
40 TCHAR szValue
[MAX_PATH
];
41 struct __LABEL_CONTEXT__
*Next
;
42 } LABEL_CONTEXT
, *PLABEL_CONTEXT
;
44 typedef struct __SOUND_SCHEME_CONTEXT__
46 TCHAR szName
[MAX_PATH
];
47 TCHAR szDesc
[MAX_PATH
];
48 PLABEL_CONTEXT LabelContext
;
49 } SOUND_SCHEME_CONTEXT
, *PSOUND_SCHEME_CONTEXT
;
51 static PLABEL_MAP s_Map
= NULL
;
52 static PAPP_MAP s_App
= NULL
;
54 TCHAR szDefault
[MAX_PATH
];
57 PLABEL_MAP
FindLabel(PAPP_MAP pAppMap
, TCHAR
* szName
)
59 PLABEL_MAP pMap
= s_Map
;
65 if (!_tcscmp(pMap
->szName
, szName
))
71 pMap
= pAppMap
->LabelMap
;
77 if (!_tcscmp(pMap
->szName
, szName
))
83 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
87 pMap
->szName
= pMap
->szDesc
= _tcsdup(szName
);
90 HeapFree(GetProcessHeap(), 0, pMap
);
94 pMap
->AppMap
= pAppMap
;
102 VOID
RemoveLabel(PLABEL_MAP pMap
)
104 PLABEL_MAP pCurMap
= s_Map
;
114 if (pCurMap
->Next
== pMap
)
116 pCurMap
->Next
= pCurMap
->Next
->Next
;
119 pCurMap
= pCurMap
->Next
;
124 PAPP_MAP
FindApp(TCHAR
* szName
)
126 PAPP_MAP pMap
= s_App
;
130 if (!_tcscmp(pMap
->szName
, szName
))
140 PLABEL_CONTEXT
FindLabelContext(PSOUND_SCHEME_CONTEXT pSoundScheme
, TCHAR
* AppName
, TCHAR
* LabelName
)
142 PLABEL_CONTEXT pLabelContext
;
144 pLabelContext
= pSoundScheme
->LabelContext
;
146 while (pLabelContext
)
148 ASSERT(pLabelContext
->AppMap
);
149 ASSERT(pLabelContext
->LabelMap
);
151 if (!_tcsicmp(pLabelContext
->AppMap
->szName
, AppName
) && !_tcsicmp(pLabelContext
->LabelMap
->szName
, LabelName
))
153 return pLabelContext
;
155 pLabelContext
= pLabelContext
->Next
;
158 pLabelContext
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_CONTEXT
));
162 pLabelContext
->AppMap
= FindApp(AppName
);
163 pLabelContext
->LabelMap
= FindLabel(pLabelContext
->AppMap
, LabelName
);
164 ASSERT(pLabelContext
->AppMap
);
165 ASSERT(pLabelContext
->LabelMap
);
166 pLabelContext
->szValue
[0] = _T('\0');
167 pLabelContext
->Next
= pSoundScheme
->LabelContext
;
168 pSoundScheme
->LabelContext
= pLabelContext
;
170 return pLabelContext
;
175 LoadEventLabel(HKEY hKey
, TCHAR
* szSubKey
)
180 TCHAR szDesc
[MAX_PATH
];
181 TCHAR szData
[MAX_PATH
];
184 if (RegOpenKeyEx(hKey
,
188 &hSubKey
) != ERROR_SUCCESS
)
193 dwDesc
= sizeof(szDesc
) / sizeof(TCHAR
);
194 if (RegQueryValueEx(hSubKey
,
199 &dwDesc
) != ERROR_SUCCESS
)
201 RegCloseKey(hSubKey
);
205 dwData
= sizeof(szDesc
) / sizeof(TCHAR
);
206 if (RegQueryValueEx(hSubKey
,
211 &dwData
) != ERROR_SUCCESS
)
213 RegCloseKey(hSubKey
);
217 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
222 pMap
->szName
= _tcsdup(szSubKey
);
223 pMap
->szDesc
= _tcsdup(szDesc
);
224 pMap
->szIcon
= _tcsdup(szData
);
245 TCHAR szName
[MAX_PATH
];
249 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
250 _T("AppEvents\\EventLabels"),
253 &hSubKey
) != ERROR_SUCCESS
)
262 dwName
= sizeof(szName
) / sizeof(szName
[0]);
263 dwResult
= RegEnumKeyEx(hSubKey
,
272 if (dwResult
== ERROR_SUCCESS
)
274 if (LoadEventLabel(hSubKey
, szName
))
281 } while (dwResult
== ERROR_SUCCESS
);
283 RegCloseKey(hSubKey
);
284 return (dwCount
!= 0);
289 AddSoundProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szSubKey
, BOOL SetDefault
)
292 TCHAR szValue
[MAX_PATH
];
293 DWORD dwValue
, dwResult
;
295 if (RegOpenKeyEx(hKey
,
299 &hSubKey
) != ERROR_SUCCESS
)
304 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
305 dwResult
= RegQueryValueEx(hSubKey
,
311 RegCloseKey(hSubKey
);
312 if (dwResult
== ERROR_SUCCESS
)
314 LRESULT lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
315 if (lResult
!= CB_ERR
)
317 PSOUND_SCHEME_CONTEXT pScheme
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SOUND_SCHEME_CONTEXT
));
320 _tcscpy(pScheme
->szDesc
, szValue
);
321 _tcscpy(pScheme
->szName
, szSubKey
);
324 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pScheme
);
327 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
337 EnumerateSoundProfiles(HWND hwndDlg
, HKEY hKey
)
340 DWORD dwName
, dwCurKey
, dwResult
, dwNumSchemes
;
341 TCHAR szName
[MAX_PATH
];
343 dwName
= sizeof(szDefault
) / sizeof(TCHAR
);
344 if (RegQueryValueEx(hKey
,
349 &dwName
) != ERROR_SUCCESS
)
356 if (RegOpenKeyEx(hKey
,
360 &hSubKey
) != ERROR_SUCCESS
)
369 dwName
= sizeof(szName
) / sizeof(szName
[0]);
370 dwResult
= RegEnumKeyEx(hSubKey
,
379 if (dwResult
== ERROR_SUCCESS
)
381 if (AddSoundProfile(hwndDlg
, hSubKey
, szName
, (!_tcsicmp(szName
, szDefault
))))
388 } while (dwResult
== ERROR_SUCCESS
);
390 RegCloseKey(hSubKey
);
395 PSOUND_SCHEME_CONTEXT
FindSoundProfile(HWND hwndDlg
, TCHAR
* szName
)
397 LRESULT lCount
, lIndex
, lResult
;
398 PSOUND_SCHEME_CONTEXT pScheme
;
400 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
401 if (lCount
== CB_ERR
)
406 for(lIndex
= 0; lIndex
< lCount
; lIndex
++)
408 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
409 if (lResult
== CB_ERR
)
414 pScheme
= (PSOUND_SCHEME_CONTEXT
)lResult
;
415 if (!_tcsicmp(pScheme
->szName
, szName
))
425 ImportSoundLabel(HWND hwndDlg
, HKEY hKey
, TCHAR
* szProfile
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP AppMap
, PLABEL_MAP LabelMap
)
428 TCHAR szValue
[MAX_PATH
];
429 TCHAR szBuffer
[MAX_PATH
];
431 PSOUND_SCHEME_CONTEXT pScheme
;
432 PLABEL_CONTEXT pLabelContext
;
433 BOOL bCurrentProfile
, bActiveProfile
;
435 //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
437 bCurrentProfile
= !_tcsicmp(szProfile
, _T(".Current"));
438 bActiveProfile
= !_tcsicmp(szProfile
, szDefault
);
440 if (RegOpenKeyEx(hKey
,
444 &hSubKey
) != ERROR_SUCCESS
)
449 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
450 if (RegQueryValueEx(hSubKey
,
455 &dwValue
) != ERROR_SUCCESS
)
461 pScheme
= FindSoundProfile(hwndDlg
, szDefault
);
463 pScheme
= FindSoundProfile(hwndDlg
, szProfile
);
467 //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
470 pLabelContext
= FindLabelContext(pScheme
, AppMap
->szName
, LabelMap
->szName
);
472 dwValue
= ExpandEnvironmentStrings(szValue
, szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
));
473 if (dwValue
== 0 || dwValue
> (sizeof(szBuffer
) / sizeof(TCHAR
)))
480 _tcscpy(pLabelContext
->szValue
, szBuffer
);
481 else if (!bActiveProfile
)
482 _tcscpy(pLabelContext
->szValue
, szBuffer
);
489 ImportSoundEntry(HWND hwndDlg
, HKEY hKey
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP pAppMap
)
496 TCHAR szProfile
[MAX_PATH
];
499 if (RegOpenKeyEx(hKey
,
503 &hSubKey
) != ERROR_SUCCESS
)
507 pLabel
= FindLabel(pAppMap
, szLabelName
);
512 pLabel
->AppMap
= pAppMap
;
513 pLabel
->Next
= pAppMap
->LabelMap
;
514 pAppMap
->LabelMap
= pLabel
;
520 dwProfile
= sizeof(szProfile
) / sizeof(TCHAR
);
521 dwResult
= RegEnumKeyEx(hSubKey
,
530 if (dwResult
== ERROR_SUCCESS
)
532 if (ImportSoundLabel(hwndDlg
, hSubKey
, szProfile
, szLabelName
, szAppName
, pAppMap
, pLabel
))
539 } while (dwResult
== ERROR_SUCCESS
);
541 RegCloseKey(hSubKey
);
543 return dwNumProfiles
;
548 ImportAppProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szAppName
)
551 TCHAR szDefault
[MAX_PATH
];
557 TCHAR szName
[MAX_PATH
];
558 TCHAR szIcon
[MAX_PATH
];
561 //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
563 AppMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(APP_MAP
));
567 if (RegOpenKeyEx(hKey
,
571 &hSubKey
) != ERROR_SUCCESS
)
573 HeapFree(GetProcessHeap(), 0, AppMap
);
577 dwDefault
= sizeof(szDefault
) / sizeof(TCHAR
);
578 if (RegQueryValueEx(hSubKey
,
583 &dwDefault
) != ERROR_SUCCESS
)
585 RegCloseKey(hSubKey
);
586 HeapFree(GetProcessHeap(), 0, AppMap
);
590 dwDefault
= sizeof(szIcon
) / sizeof(TCHAR
);
591 if (RegQueryValueEx(hSubKey
,
596 &dwDefault
) != ERROR_SUCCESS
)
598 szIcon
[0] = _T('\0');
601 /* initialize app map */
602 _tcscpy(AppMap
->szName
, szAppName
);
603 _tcscpy(AppMap
->szDesc
, szDefault
);
604 _tcscpy(AppMap
->szIcon
, szIcon
);
606 AppMap
->Next
= s_App
;
614 dwName
= sizeof(szName
) / sizeof(TCHAR
);
615 dwResult
= RegEnumKeyEx(hSubKey
,
623 if (dwResult
== ERROR_SUCCESS
)
625 if (ImportSoundEntry(hwndDlg
, hSubKey
, szName
, szAppName
, AppMap
))
631 } while (dwResult
== ERROR_SUCCESS
);
633 RegCloseKey(hSubKey
);
639 ImportSoundProfiles(HWND hwndDlg
, HKEY hKey
)
644 TCHAR szName
[MAX_PATH
];
647 if (RegOpenKeyEx(hKey
,
651 &hSubKey
) != ERROR_SUCCESS
)
660 dwResult
= RegEnumKey(hSubKey
,
663 sizeof(szName
) / sizeof(TCHAR
));
665 if (dwResult
== ERROR_SUCCESS
)
667 if (ImportAppProfile(hwndDlg
, hSubKey
, szName
))
673 } while (dwResult
== ERROR_SUCCESS
);
675 RegCloseKey(hSubKey
);
677 return (dwNumApps
!= 0);
682 LoadSoundProfiles(HWND hwndDlg
)
687 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
688 _T("AppEvents\\Schemes"),
691 &hSubKey
) != ERROR_SUCCESS
)
696 dwNumSchemes
= EnumerateSoundProfiles(hwndDlg
, hSubKey
);
701 //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
702 ImportSoundProfiles(hwndDlg
, hSubKey
);
705 RegCloseKey(hSubKey
);
711 LoadSoundFiles(HWND hwndDlg
)
713 WCHAR szPath
[MAX_PATH
];
715 WIN32_FIND_DATAW FileData
;
720 /* Add no sound listview item */
721 if (LoadString(hApplet
, IDS_NO_SOUND
, szPath
, MAX_PATH
))
723 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
724 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szPath
);
727 /* Load sound files */
728 length
= GetWindowsDirectoryW(szPath
, MAX_PATH
);
729 if (length
== 0 || length
>= MAX_PATH
- 9)
733 if (szPath
[length
-1] != L
'\\')
735 szPath
[length
] = L
'\\';
738 wcscpy(&szPath
[length
], L
"media\\*");
741 hFile
= FindFirstFileW(szPath
, &FileData
);
742 if (hFile
== INVALID_HANDLE_VALUE
)
749 if (FileData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
752 ptr
= wcsrchr(FileData
.cFileName
, L
'\\');
759 ptr
= FileData
.cFileName
;
761 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
762 if (lResult
!= CB_ERR
)
764 wcscpy(&szPath
[length
-1], FileData
.cFileName
);
765 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(szPath
));
767 } while (FindNextFileW(hFile
, &FileData
) != 0);
775 ShowSoundScheme(HWND hwndDlg
)
778 PSOUND_SCHEME_CONTEXT pScheme
;
782 HWND hDlgCtrl
, hList
;
785 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
786 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
788 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
789 if (lIndex
== CB_ERR
)
794 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
795 if (lIndex
== CB_ERR
)
799 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
801 _tcscpy(szDefault
, pScheme
->szName
);
803 /* add column for app */
804 GetClientRect(hList
, &rect
);
805 ZeroMemory(&dummy
, sizeof(LV_COLUMN
));
806 dummy
.mask
= LVCF_WIDTH
;
808 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
809 (void)ListView_InsertColumn(hList
, 0, &dummy
);
815 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
818 ZeroMemory(&listItem
, sizeof(LV_ITEM
));
819 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
820 listItem
.pszText
= pLabelMap
->szDesc
;
821 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
822 listItem
.iItem
= ItemIndex
;
823 listItem
.iImage
= -1;
824 (void)ListView_InsertItem(hList
, &listItem
);
827 pLabelMap
= pLabelMap
->Next
;
829 pAppMap
= pAppMap
->Next
;
836 ApplyChanges(HWND hwndDlg
)
840 PSOUND_SCHEME_CONTEXT pScheme
;
842 PLABEL_CONTEXT pLabelContext
;
845 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
847 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
848 if (lIndex
== CB_ERR
)
853 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
854 if (lIndex
== CB_ERR
)
858 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
860 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
861 _T("AppEvents\\Schemes"),
864 &hKey
) != ERROR_SUCCESS
)
869 RegSetValueEx(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pScheme
->szName
, (_tcslen(pScheme
->szName
) +1) * sizeof(TCHAR
));
872 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
873 _T("AppEvents\\Schemes\\Apps"),
876 &hKey
) != ERROR_SUCCESS
)
881 pLabelContext
= pScheme
->LabelContext
;
883 while (pLabelContext
)
885 _stprintf(Buffer
, _T("%s\\%s\\.Current"), pLabelContext
->AppMap
->szName
, pLabelContext
->LabelMap
->szName
);
887 if (RegOpenKeyEx(hKey
, Buffer
, 0, KEY_WRITE
, &hSubKey
) == ERROR_SUCCESS
)
889 RegSetValueEx(hSubKey
, NULL
, 0, REG_EXPAND_SZ
, (LPBYTE
)pLabelContext
->szValue
, (_tcslen(pLabelContext
->szValue
) +1) * sizeof(TCHAR
));
890 RegCloseKey(hSubKey
);
893 pLabelContext
= pLabelContext
->Next
;
897 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, (LONG
)PSNRET_NOERROR
);
902 /* Sounds property page dialog callback */
905 SoundsDlgProc(HWND hwndDlg
,
911 WCHAR filename
[MAX_PATH
];
919 UINT NumWavOut
= waveOutGetNumDevs();
921 SendMessage(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
),
922 BM_SETIMAGE
,(WPARAM
)IMAGE_ICON
,
923 (LPARAM
)(HANDLE
)LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_PLAY_ICON
)));
926 LoadSoundProfiles(hwndDlg
);
927 LoadSoundFiles(hwndDlg
);
928 ShowSoundScheme(hwndDlg
);
932 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), FALSE
);
933 EnableWindow(GetDlgItem(hwndDlg
, IDC_SAVEAS_BTN
), FALSE
);
934 EnableWindow(GetDlgItem(hwndDlg
, IDC_DELETE_BTN
), FALSE
);
935 EnableWindow(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), FALSE
);
938 if (wParam
== (WPARAM
)GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
))
940 SetFocus(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
945 switch (LOWORD(wParam
))
947 case IDC_BROWSE_SOUND
:
949 ZeroMemory(&ofn
, sizeof(OPENFILENAMEW
));
950 ofn
.lStructSize
= sizeof(OPENFILENAMEW
);
951 ofn
.hwndOwner
= hwndDlg
;
952 ofn
.lpstrFile
= filename
;
953 ofn
.lpstrFile
[0] = L
'\0';
954 ofn
.nMaxFile
= MAX_PATH
;
955 ofn
.lpstrFilter
= L
"Wave Files (*.wav)\0*.wav\0"; //FIXME non-nls
956 ofn
.nFilterIndex
= 0;
957 ofn
.lpstrFileTitle
= L
"Search for new sounds"; //FIXME non-nls
958 ofn
.nMaxFileTitle
= wcslen(ofn
.lpstrFileTitle
);
959 ofn
.lpstrInitialDir
= NULL
;
960 ofn
.Flags
= OFN_FILEMUSTEXIST
| OFN_HIDEREADONLY
;
962 if (GetOpenFileNameW(&ofn
) == TRUE
)
964 // FIXME search if list already contains that sound
967 pFileName
= wcsrchr(filename
, L
'\\');
968 ASSERT(pFileName
!= NULL
);
972 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)pFileName
);
973 if (lResult
!= CB_ERR
)
975 // add path and select item
976 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(filename
));
977 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
985 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
986 if (lIndex
== CB_ERR
)
991 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
992 if (lIndex
!= CB_ERR
)
994 PlaySound((TCHAR
*)lIndex
, NULL
, SND_FILENAME
);
998 case IDC_SOUND_SCHEME
:
1000 if (HIWORD(wParam
) == CBN_SELENDOK
)
1002 (void)ListView_DeleteAllItems(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
1003 ShowSoundScheme(hwndDlg
);
1004 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), FALSE
);
1005 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), FALSE
);
1006 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1007 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), FALSE
);
1008 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1012 case IDC_SOUND_LIST
:
1014 if (HIWORD(wParam
) == CBN_SELENDOK
)
1016 PLABEL_CONTEXT pLabelContext
;
1020 SelCount
= ListView_GetSelectionMark(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
1025 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1026 if (lIndex
== CB_ERR
)
1030 ZeroMemory(&item
, sizeof(LVITEM
));
1031 item
.mask
= LVIF_PARAM
;
1032 item
.iItem
= SelCount
;
1033 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1036 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1038 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1039 if (lResult
== CB_ERR
|| lResult
== 0)
1041 if (lIndex
!= pLabelContext
->szValue
[0])
1042 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1044 pLabelContext
->szValue
[0] = L
'\0';
1048 if (_tcsicmp(pLabelContext
->szValue
, (TCHAR
*)lResult
) || (lIndex
!= pLabelContext
->szValue
[0]))
1050 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1052 /// Should store in current member
1054 _tcscpy(pLabelContext
->szValue
, (TCHAR
*)lResult
);
1056 if (_tcslen((TCHAR
*)lResult
) && lIndex
!= 0)
1058 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1062 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1074 PLABEL_CONTEXT pLabelContext
;
1077 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1083 ApplyChanges(hwndDlg
);
1086 case LVN_ITEMCHANGED
:
1088 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1090 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1094 ZeroMemory(&item
, sizeof(LVITEM
));
1095 item
.mask
= LVIF_PARAM
;
1096 item
.iItem
= nm
->iItem
;
1098 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1100 LRESULT lCount
, lIndex
, lResult
;
1101 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1106 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1107 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1108 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1109 if (_tcslen(pLabelContext
->szValue
) == 0)
1111 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1112 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1116 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1117 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
1118 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1120 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1121 if (lResult
== CB_ERR
|| lResult
== 0)
1124 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1126 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);
1130 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1137 ptr
= pLabelContext
->szValue
;
1139 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
1140 if (lIndex
!= CB_ERR
)
1142 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)_tcsdup(pLabelContext
->szValue
));
1143 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);