1 /* $Id: main.c 12852 2005-01-06 13:58:04Z mf $
3 * PROJECT: ReactOS Multimedia Control Panel
4 * FILE: lib/cpl/mmsys/mmsys.c
5 * PURPOSE: ReactOS Multimedia Control Panel
6 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
7 * Johannes Anderwald <janderwald@reactos.com>
8 * Dmitry Chapyshev <dmitry@reactos.org>
15 typedef struct __LABEL_MAP__
20 struct __APP_MAP__
* AppMap
;
21 struct __LABEL_MAP__
* Next
;
22 }LABEL_MAP
, *PLABEL_MAP
;
24 typedef struct __APP_MAP__
26 TCHAR szName
[MAX_PATH
];
27 TCHAR szDesc
[MAX_PATH
];
28 TCHAR szIcon
[MAX_PATH
];
30 struct __APP_MAP__
*Next
;
34 typedef struct __LABEL_CONTEXT__
38 TCHAR szValue
[MAX_PATH
];
39 struct __LABEL_CONTEXT__
*Next
;
40 }LABEL_CONTEXT
, *PLABEL_CONTEXT
;
42 typedef struct __SOUND_SCHEME_CONTEXT__
44 TCHAR szName
[MAX_PATH
];
45 TCHAR szDesc
[MAX_PATH
];
46 PLABEL_CONTEXT LabelContext
;
47 }SOUND_SCHEME_CONTEXT
, *PSOUND_SCHEME_CONTEXT
;
49 static PLABEL_MAP s_Map
= NULL
;
50 static PAPP_MAP s_App
= NULL
;
52 TCHAR szDefault
[MAX_PATH
];
55 PLABEL_MAP
FindLabel(PAPP_MAP pAppMap
, TCHAR
* szName
)
57 PLABEL_MAP pMap
= s_Map
;
63 if (!_tcscmp(pMap
->szName
, szName
))
70 pMap
= pAppMap
->LabelMap
;
76 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
);
93 pMap
->AppMap
= pAppMap
;
100 VOID
RemoveLabel(PLABEL_MAP pMap
)
102 PLABEL_MAP pCurMap
= s_Map
;
113 if (pCurMap
->Next
== pMap
)
115 pCurMap
->Next
= pCurMap
->Next
->Next
;
118 pCurMap
= pCurMap
->Next
;
127 PAPP_MAP
FindApp(TCHAR
* szName
)
129 PAPP_MAP pMap
= s_App
;
133 if (!_tcscmp(pMap
->szName
, szName
))
142 PLABEL_CONTEXT
FindLabelContext(PSOUND_SCHEME_CONTEXT pSoundScheme
, TCHAR
* AppName
, TCHAR
* LabelName
)
144 PLABEL_CONTEXT pLabelContext
;
146 pLabelContext
= pSoundScheme
->LabelContext
;
150 ASSERT(pLabelContext
->AppMap
);
151 ASSERT(pLabelContext
->LabelMap
);
153 if(!_tcsicmp(pLabelContext
->AppMap
->szName
, AppName
) && !_tcsicmp(pLabelContext
->LabelMap
->szName
, LabelName
))
155 return pLabelContext
;
157 pLabelContext
= pLabelContext
->Next
;
160 pLabelContext
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_CONTEXT
));
164 pLabelContext
->AppMap
= FindApp(AppName
);
165 pLabelContext
->LabelMap
= FindLabel(pLabelContext
->AppMap
, LabelName
);
166 ASSERT(pLabelContext
->AppMap
);
167 ASSERT(pLabelContext
->LabelMap
);
168 pLabelContext
->szValue
[0] = _T('\0');
169 pLabelContext
->Next
= pSoundScheme
->LabelContext
;
170 pSoundScheme
->LabelContext
= pLabelContext
;
172 return pLabelContext
;
176 LoadEventLabel(HKEY hKey
, TCHAR
* szSubKey
)
181 TCHAR szDesc
[MAX_PATH
];
182 TCHAR szData
[MAX_PATH
];
185 if (RegOpenKeyEx(hKey
,
189 &hSubKey
) != ERROR_SUCCESS
)
194 dwDesc
= sizeof(szDesc
) / sizeof(TCHAR
);
195 if (RegQueryValueEx(hSubKey
,
200 &dwDesc
) != ERROR_SUCCESS
)
202 RegCloseKey(hSubKey
);
206 dwData
= sizeof(szDesc
) / sizeof(TCHAR
);
207 if (RegQueryValueEx(hSubKey
,
212 &dwData
) != ERROR_SUCCESS
)
214 RegCloseKey(hSubKey
);
218 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
223 pMap
->szName
= _tcsdup(szSubKey
);
224 pMap
->szDesc
= _tcsdup(szDesc
);
225 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);
288 AddSoundProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szSubKey
, BOOL SetDefault
)
291 TCHAR szValue
[MAX_PATH
];
292 DWORD dwValue
, dwResult
;
294 if (RegOpenKeyEx(hKey
,
298 &hSubKey
) != ERROR_SUCCESS
)
303 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
304 dwResult
= RegQueryValueEx(hSubKey
,
310 RegCloseKey(hSubKey
);
311 if (dwResult
== ERROR_SUCCESS
)
313 LRESULT lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
314 if (lResult
!= CB_ERR
)
316 PSOUND_SCHEME_CONTEXT pScheme
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SOUND_SCHEME_CONTEXT
));
319 _tcscpy(pScheme
->szDesc
, szValue
);
320 _tcscpy(pScheme
->szName
, szSubKey
);
323 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pScheme
);
326 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
335 EnumerateSoundProfiles(HWND hwndDlg
, HKEY hKey
)
338 DWORD dwName
, dwCurKey
, dwResult
, dwNumSchemes
;
339 TCHAR szName
[MAX_PATH
];
341 dwName
= sizeof(szDefault
) / sizeof(TCHAR
);
342 if (RegQueryValueEx(hKey
,
347 &dwName
) != ERROR_SUCCESS
)
354 if (RegOpenKeyEx(hKey
,
358 &hSubKey
) != ERROR_SUCCESS
)
367 dwName
= sizeof(szName
) / sizeof(szName
[0]);
368 dwResult
= RegEnumKeyEx(hSubKey
,
377 if (dwResult
== ERROR_SUCCESS
)
379 if (AddSoundProfile(hwndDlg
, hSubKey
, szName
, (!_tcsicmp(szName
, szDefault
))))
386 }while(dwResult
== ERROR_SUCCESS
);
388 RegCloseKey(hSubKey
);
392 PSOUND_SCHEME_CONTEXT
FindSoundProfile(HWND hwndDlg
, TCHAR
* szName
)
394 LRESULT lCount
, lIndex
, lResult
;
395 PSOUND_SCHEME_CONTEXT pScheme
;
397 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
398 if (lCount
== CB_ERR
)
403 for(lIndex
= 0; lIndex
< lCount
; lIndex
++)
405 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
406 if (lResult
== CB_ERR
)
411 pScheme
= (PSOUND_SCHEME_CONTEXT
)lResult
;
412 if (!_tcsicmp(pScheme
->szName
, szName
))
420 ImportSoundLabel(HWND hwndDlg
, HKEY hKey
, TCHAR
* szProfile
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP AppMap
, PLABEL_MAP LabelMap
)
423 TCHAR szValue
[MAX_PATH
];
424 TCHAR szBuffer
[MAX_PATH
];
426 PSOUND_SCHEME_CONTEXT pScheme
;
427 PLABEL_CONTEXT pLabelContext
;
428 BOOL bCurrentProfile
, bActiveProfile
;
431 //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
433 bCurrentProfile
= !_tcsicmp(szProfile
, _T(".Current"));
434 bActiveProfile
= !_tcsicmp(szProfile
, szDefault
);
437 if (RegOpenKeyEx(hKey
,
441 &hSubKey
) != ERROR_SUCCESS
)
446 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
447 if (RegQueryValueEx(hSubKey
,
452 &dwValue
) != ERROR_SUCCESS
)
458 pScheme
= FindSoundProfile(hwndDlg
, szDefault
);
460 pScheme
= FindSoundProfile(hwndDlg
, szProfile
);
464 //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
467 pLabelContext
= FindLabelContext(pScheme
, AppMap
->szName
, LabelMap
->szName
);
469 dwValue
= ExpandEnvironmentStrings(szValue
, szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
));
470 if (dwValue
== 0 || dwValue
> (sizeof(szBuffer
) / sizeof(TCHAR
)))
477 _tcscpy(pLabelContext
->szValue
, szBuffer
);
478 else if (!bActiveProfile
)
479 _tcscpy(pLabelContext
->szValue
, szBuffer
);
486 ImportSoundEntry(HWND hwndDlg
, HKEY hKey
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP pAppMap
)
493 TCHAR szProfile
[MAX_PATH
];
496 if (RegOpenKeyEx(hKey
,
500 &hSubKey
) != ERROR_SUCCESS
)
504 pLabel
= FindLabel(pAppMap
, szLabelName
);
509 pLabel
->AppMap
= pAppMap
;
510 pLabel
->Next
= pAppMap
->LabelMap
;
511 pAppMap
->LabelMap
= pLabel
;
517 dwProfile
= sizeof(szProfile
) / sizeof(TCHAR
);
518 dwResult
= RegEnumKeyEx(hSubKey
,
527 if (dwResult
== ERROR_SUCCESS
)
529 if (ImportSoundLabel(hwndDlg
, hSubKey
, szProfile
, szLabelName
, szAppName
, pAppMap
, pLabel
))
536 }while(dwResult
== ERROR_SUCCESS
);
538 RegCloseKey(hSubKey
);
540 return dwNumProfiles
;
546 ImportAppProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szAppName
)
549 TCHAR szDefault
[MAX_PATH
];
555 TCHAR szName
[MAX_PATH
];
556 TCHAR szIcon
[MAX_PATH
];
559 //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
561 AppMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(APP_MAP
));
565 if (RegOpenKeyEx(hKey
,
569 &hSubKey
) != ERROR_SUCCESS
)
571 HeapFree(GetProcessHeap(), 0, AppMap
);
575 dwDefault
= sizeof(szDefault
) / sizeof(TCHAR
);
576 if (RegQueryValueEx(hSubKey
,
581 &dwDefault
) != ERROR_SUCCESS
)
583 RegCloseKey(hSubKey
);
584 HeapFree(GetProcessHeap(), 0, AppMap
);
588 dwDefault
= sizeof(szIcon
) / sizeof(TCHAR
);
589 if (RegQueryValueEx(hSubKey
,
594 &dwDefault
) != ERROR_SUCCESS
)
596 szIcon
[0] = _T('\0');
599 /* initialize app map */
600 _tcscpy(AppMap
->szName
, szAppName
);
601 _tcscpy(AppMap
->szDesc
, szDefault
);
602 _tcscpy(AppMap
->szIcon
, szIcon
);
604 AppMap
->Next
= s_App
;
612 dwName
= sizeof(szName
) / sizeof(TCHAR
);
613 dwResult
= RegEnumKeyEx(hSubKey
,
621 if (dwResult
== ERROR_SUCCESS
)
623 if (ImportSoundEntry(hwndDlg
, hSubKey
, szName
, szAppName
, AppMap
))
629 }while(dwResult
== ERROR_SUCCESS
);
630 RegCloseKey(hSubKey
);
635 ImportSoundProfiles(HWND hwndDlg
, HKEY hKey
)
640 TCHAR szName
[MAX_PATH
];
643 if (RegOpenKeyEx(hKey
,
647 &hSubKey
) != ERROR_SUCCESS
)
656 dwResult
= RegEnumKey(hSubKey
,
659 sizeof(szName
) / sizeof(TCHAR
));
661 if (dwResult
== ERROR_SUCCESS
)
663 if (ImportAppProfile(hwndDlg
, hSubKey
, szName
))
669 }while(dwResult
== ERROR_SUCCESS
);
670 RegCloseKey(hSubKey
);
672 return (dwNumApps
!= 0);
678 LoadSoundProfiles(HWND hwndDlg
)
683 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
684 _T("AppEvents\\Schemes"),
687 &hSubKey
) != ERROR_SUCCESS
)
692 dwNumSchemes
= EnumerateSoundProfiles(hwndDlg
, hSubKey
);
697 //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
698 ImportSoundProfiles(hwndDlg
, hSubKey
);
700 RegCloseKey(hSubKey
);
704 LoadSoundFiles(HWND hwndDlg
)
706 WCHAR szPath
[MAX_PATH
];
708 WIN32_FIND_DATAW FileData
;
713 /* Add no sound listview item */
714 if (LoadString(hApplet
, IDS_NO_SOUND
, szPath
, MAX_PATH
))
716 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
717 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szPath
);
720 /* Load sound files */
721 length
= GetWindowsDirectoryW(szPath
, MAX_PATH
);
722 if (length
== 0 || length
>= MAX_PATH
- 9)
726 if (szPath
[length
-1] != L
'\\')
728 szPath
[length
] = L
'\\';
731 wcscpy(&szPath
[length
], L
"media\\*");
734 hFile
= FindFirstFileW(szPath
, &FileData
);
735 if (hFile
== INVALID_HANDLE_VALUE
)
742 if (FileData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
745 ptr
= wcsrchr(FileData
.cFileName
, L
'\\');
752 ptr
= FileData
.cFileName
;
754 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
755 if (lResult
!= CB_ERR
)
757 wcscpy(&szPath
[length
-1], FileData
.cFileName
);
758 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(szPath
));
760 }while(FindNextFileW(hFile
, &FileData
) != 0);
769 ShowSoundScheme(HWND hwndDlg
)
772 PSOUND_SCHEME_CONTEXT pScheme
;
776 HWND hDlgCtrl
, hList
;
779 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
780 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
782 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
783 if (lIndex
== CB_ERR
)
788 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
789 if (lIndex
== CB_ERR
)
793 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
795 _tcscpy(szDefault
, pScheme
->szName
);
797 /* add column for app */
798 GetClientRect(hList
, &rect
);
799 ZeroMemory(&dummy
, sizeof(LV_COLUMN
));
800 dummy
.mask
= LVCF_WIDTH
;
802 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
803 (void)ListView_InsertColumn(hList
, 0, &dummy
);
809 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
812 ZeroMemory(&listItem
, sizeof(LV_ITEM
));
813 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
814 listItem
.pszText
= pLabelMap
->szDesc
;
815 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
816 listItem
.iItem
= ItemIndex
;
817 listItem
.iImage
= -1;
818 (void)ListView_InsertItem(hList
, &listItem
);
821 pLabelMap
= pLabelMap
->Next
;
823 pAppMap
= pAppMap
->Next
;
829 ApplyChanges(HWND hwndDlg
)
833 PSOUND_SCHEME_CONTEXT pScheme
;
835 PLABEL_CONTEXT pLabelContext
;
838 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
840 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
841 if (lIndex
== CB_ERR
)
846 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
847 if (lIndex
== CB_ERR
)
851 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
853 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
854 _T("AppEvents\\Schemes"),
857 &hKey
) != ERROR_SUCCESS
)
862 RegSetValueEx(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pScheme
->szName
, (_tcslen(pScheme
->szName
) +1) * sizeof(TCHAR
));
865 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
866 _T("AppEvents\\Schemes\\Apps"),
869 &hKey
) != ERROR_SUCCESS
)
874 pLabelContext
= pScheme
->LabelContext
;
878 _stprintf(Buffer
, _T("%s\\%s\\.Current"), pLabelContext
->AppMap
->szName
, pLabelContext
->LabelMap
->szName
);
880 if (RegOpenKeyEx(hKey
, Buffer
, 0, KEY_WRITE
, &hSubKey
) == ERROR_SUCCESS
)
882 RegSetValueEx(hSubKey
, NULL
, 0, REG_EXPAND_SZ
, (LPBYTE
)pLabelContext
->szValue
, (_tcslen(pLabelContext
->szValue
) +1) * sizeof(TCHAR
));
883 RegCloseKey(hSubKey
);
886 pLabelContext
= pLabelContext
->Next
;
890 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, (LONG
)PSNRET_NOERROR
);
895 /* Sounds property page dialog callback */
898 SoundsDlgProc(HWND hwndDlg
,
907 UINT NumWavOut
= waveOutGetNumDevs();
909 SendMessage(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
),
910 BM_SETIMAGE
,(WPARAM
)IMAGE_ICON
,
911 (LPARAM
)(HANDLE
)LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_PLAY_ICON
)));
914 LoadSoundProfiles(hwndDlg
);
915 LoadSoundFiles(hwndDlg
);
916 ShowSoundScheme(hwndDlg
);
920 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), FALSE
);
921 EnableWindow(GetDlgItem(hwndDlg
, IDC_SAVEAS_BTN
), FALSE
);
922 EnableWindow(GetDlgItem(hwndDlg
, IDC_DELETE_BTN
), FALSE
);
923 EnableWindow(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), FALSE
);
926 if (wParam
== (WPARAM
)GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
))
928 SetFocus(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
933 switch(LOWORD(wParam
))
938 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
939 if (lIndex
== CB_ERR
)
944 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
945 if (lIndex
!= CB_ERR
)
947 PlaySound((TCHAR
*)lIndex
, NULL
, SND_FILENAME
);
951 case IDC_SOUND_SCHEME
:
953 if (HIWORD(wParam
) == CBN_SELENDOK
)
955 (void)ListView_DeleteAllItems(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
956 ShowSoundScheme(hwndDlg
);
957 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), FALSE
);
958 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), FALSE
);
959 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
960 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), FALSE
);
961 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
967 if (HIWORD(wParam
) == CBN_SELENDOK
)
969 PLABEL_CONTEXT pLabelContext
;
973 SelCount
= ListView_GetSelectionMark(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
978 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
979 if (lIndex
== CB_ERR
)
983 ZeroMemory(&item
, sizeof(LVITEM
));
984 item
.mask
= LVIF_PARAM
;
985 item
.iItem
= SelCount
;
986 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
989 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
991 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
992 if (lResult
== CB_ERR
|| lResult
== 0)
994 if (lIndex
!= pLabelContext
->szValue
[0])
995 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
997 pLabelContext
->szValue
[0] = L
'\0';
1001 if (_tcsicmp(pLabelContext
->szValue
, (TCHAR
*)lResult
) || (lIndex
!= pLabelContext
->szValue
[0]))
1003 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1005 /// should store in current member
1007 _tcscpy(pLabelContext
->szValue
, (TCHAR
*)lResult
);
1009 if (_tcslen((TCHAR
*)lResult
) && lIndex
!= 0)
1011 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1015 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1027 PLABEL_CONTEXT pLabelContext
;
1031 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1032 lppsn
= (LPPSHNOTIFY
) lParam
;
1038 ApplyChanges(hwndDlg
);
1041 case LVN_ITEMCHANGED
:
1043 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1045 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1049 ZeroMemory(&item
, sizeof(LVITEM
));
1050 item
.mask
= LVIF_PARAM
;
1051 item
.iItem
= nm
->iItem
;
1053 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1055 LRESULT lCount
, lIndex
, lResult
;
1056 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1061 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1062 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1063 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1064 if (_tcslen(pLabelContext
->szValue
) == 0)
1066 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1067 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1071 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1072 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
1073 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1075 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1076 if (lResult
== CB_ERR
|| lResult
== 0)
1079 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1081 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);
1085 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1092 ptr
= pLabelContext
->szValue
;
1094 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
1095 if (lIndex
!= CB_ERR
)
1097 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)_tcsdup(pLabelContext
->szValue
));
1098 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);