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>
23 typedef struct __LABEL_MAP__
28 struct __APP_MAP__
* AppMap
;
29 struct __LABEL_MAP__
* Next
;
30 }LABEL_MAP
, *PLABEL_MAP
;
32 typedef struct __APP_MAP__
34 TCHAR szName
[MAX_PATH
];
35 TCHAR szDesc
[MAX_PATH
];
36 TCHAR szIcon
[MAX_PATH
];
38 struct __APP_MAP__
*Next
;
42 typedef struct __LABEL_CONTEXT__
46 TCHAR szValue
[MAX_PATH
];
47 struct __LABEL_CONTEXT__
*Next
;
48 }LABEL_CONTEXT
, *PLABEL_CONTEXT
;
50 typedef struct __SOUND_SCHEME_CONTEXT__
52 TCHAR szName
[MAX_PATH
];
53 TCHAR szDesc
[MAX_PATH
];
54 PLABEL_CONTEXT LabelContext
;
55 }SOUND_SCHEME_CONTEXT
, *PSOUND_SCHEME_CONTEXT
;
57 static PLABEL_MAP s_Map
= NULL
;
58 static PAPP_MAP s_App
= NULL
;
60 TCHAR szDefault
[MAX_PATH
];
63 PLABEL_MAP
FindLabel(PAPP_MAP pAppMap
, TCHAR
* szName
)
65 PLABEL_MAP pMap
= s_Map
;
71 if (!_tcscmp(pMap
->szName
, szName
))
78 pMap
= pAppMap
->LabelMap
;
84 if (!_tcscmp(pMap
->szName
, szName
))
91 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
95 pMap
->szName
= pMap
->szDesc
= _tcsdup(szName
);
98 HeapFree(GetProcessHeap(), 0, pMap
);
101 pMap
->AppMap
= pAppMap
;
108 VOID
RemoveLabel(PLABEL_MAP pMap
)
110 PLABEL_MAP pCurMap
= s_Map
;
121 if (pCurMap
->Next
== pMap
)
123 pCurMap
->Next
= pCurMap
->Next
->Next
;
126 pCurMap
= pCurMap
->Next
;
135 PAPP_MAP
FindApp(TCHAR
* szName
)
137 PAPP_MAP pMap
= s_App
;
141 if (!_tcscmp(pMap
->szName
, szName
))
150 PLABEL_CONTEXT
FindLabelContext(PSOUND_SCHEME_CONTEXT pSoundScheme
, TCHAR
* AppName
, TCHAR
* LabelName
)
152 PLABEL_CONTEXT pLabelContext
;
154 pLabelContext
= pSoundScheme
->LabelContext
;
158 ASSERT(pLabelContext
->AppMap
);
159 ASSERT(pLabelContext
->LabelMap
);
161 if(!_tcsicmp(pLabelContext
->AppMap
->szName
, AppName
) && !_tcsicmp(pLabelContext
->LabelMap
->szName
, LabelName
))
163 return pLabelContext
;
165 pLabelContext
= pLabelContext
->Next
;
168 pLabelContext
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_CONTEXT
));
172 pLabelContext
->AppMap
= FindApp(AppName
);
173 pLabelContext
->LabelMap
= FindLabel(pLabelContext
->AppMap
, LabelName
);
174 ASSERT(pLabelContext
->AppMap
);
175 ASSERT(pLabelContext
->LabelMap
);
176 pLabelContext
->szValue
[0] = _T('\0');
177 pLabelContext
->Next
= pSoundScheme
->LabelContext
;
178 pSoundScheme
->LabelContext
= pLabelContext
;
180 return pLabelContext
;
184 LoadEventLabel(HKEY hKey
, TCHAR
* szSubKey
)
189 TCHAR szDesc
[MAX_PATH
];
190 TCHAR szData
[MAX_PATH
];
193 if (RegOpenKeyEx(hKey
,
197 &hSubKey
) != ERROR_SUCCESS
)
202 dwDesc
= sizeof(szDesc
) / sizeof(TCHAR
);
203 if (RegQueryValueEx(hSubKey
,
208 &dwDesc
) != ERROR_SUCCESS
)
210 RegCloseKey(hSubKey
);
214 dwData
= sizeof(szDesc
) / sizeof(TCHAR
);
215 if (RegQueryValueEx(hSubKey
,
220 &dwData
) != ERROR_SUCCESS
)
222 RegCloseKey(hSubKey
);
226 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
231 pMap
->szName
= _tcsdup(szSubKey
);
232 pMap
->szDesc
= _tcsdup(szDesc
);
233 pMap
->szIcon
= _tcsdup(szData
);
253 TCHAR szName
[MAX_PATH
];
257 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
258 _T("AppEvents\\EventLabels"),
261 &hSubKey
) != ERROR_SUCCESS
)
270 dwName
= sizeof(szName
) / sizeof(szName
[0]);
271 dwResult
= RegEnumKeyEx(hSubKey
,
280 if (dwResult
== ERROR_SUCCESS
)
282 if (LoadEventLabel(hSubKey
, szName
))
289 }while(dwResult
== ERROR_SUCCESS
);
291 RegCloseKey(hSubKey
);
292 return (dwCount
!= 0);
296 AddSoundProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szSubKey
, BOOL SetDefault
)
299 TCHAR szValue
[MAX_PATH
];
300 DWORD dwValue
, dwResult
;
302 if (RegOpenKeyEx(hKey
,
306 &hSubKey
) != ERROR_SUCCESS
)
311 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
312 dwResult
= RegQueryValueEx(hSubKey
,
318 RegCloseKey(hSubKey
);
319 if (dwResult
== ERROR_SUCCESS
)
321 LRESULT lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
322 if (lResult
!= CB_ERR
)
324 PSOUND_SCHEME_CONTEXT pScheme
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SOUND_SCHEME_CONTEXT
));
327 _tcscpy(pScheme
->szDesc
, szValue
);
328 _tcscpy(pScheme
->szName
, szSubKey
);
331 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pScheme
);
334 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETCURSEL
, (WPARAM
)lResult
, (LPARAM
)0);
343 EnumerateSoundProfiles(HWND hwndDlg
, HKEY hKey
)
346 DWORD dwName
, dwCurKey
, dwResult
, dwNumSchemes
;
347 TCHAR szName
[MAX_PATH
];
349 dwName
= sizeof(szDefault
) / sizeof(TCHAR
);
350 if (RegQueryValueEx(hKey
,
355 &dwName
) != ERROR_SUCCESS
)
362 if (RegOpenKeyEx(hKey
,
366 &hSubKey
) != ERROR_SUCCESS
)
375 dwName
= sizeof(szName
) / sizeof(szName
[0]);
376 dwResult
= RegEnumKeyEx(hSubKey
,
385 if (dwResult
== ERROR_SUCCESS
)
387 if (AddSoundProfile(hwndDlg
, hSubKey
, szName
, (!_tcsicmp(szName
, szDefault
))))
394 }while(dwResult
== ERROR_SUCCESS
);
396 RegCloseKey(hSubKey
);
400 PSOUND_SCHEME_CONTEXT
FindSoundProfile(HWND hwndDlg
, TCHAR
* szName
)
402 LRESULT lCount
, lIndex
, lResult
;
403 PSOUND_SCHEME_CONTEXT pScheme
;
405 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
406 if (lCount
== CB_ERR
)
411 for(lIndex
= 0; lIndex
< lCount
; lIndex
++)
413 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
414 if (lResult
== CB_ERR
)
419 pScheme
= (PSOUND_SCHEME_CONTEXT
)lResult
;
420 if (!_tcsicmp(pScheme
->szName
, szName
))
428 ImportSoundLabel(HWND hwndDlg
, HKEY hKey
, TCHAR
* szProfile
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP AppMap
, PLABEL_MAP LabelMap
)
431 TCHAR szValue
[MAX_PATH
];
432 TCHAR szBuffer
[MAX_PATH
];
434 PSOUND_SCHEME_CONTEXT pScheme
;
435 PLABEL_CONTEXT pLabelContext
;
436 BOOL bCurrentProfile
, bActiveProfile
;
439 //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
441 bCurrentProfile
= !_tcsicmp(szProfile
, _T(".Current"));
442 bActiveProfile
= !_tcsicmp(szProfile
, szDefault
);
445 if (RegOpenKeyEx(hKey
,
449 &hSubKey
) != ERROR_SUCCESS
)
454 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
455 if (RegQueryValueEx(hSubKey
,
460 &dwValue
) != ERROR_SUCCESS
)
466 pScheme
= FindSoundProfile(hwndDlg
, szDefault
);
468 pScheme
= FindSoundProfile(hwndDlg
, szProfile
);
472 //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
475 pLabelContext
= FindLabelContext(pScheme
, AppMap
->szName
, LabelMap
->szName
);
477 dwValue
= ExpandEnvironmentStrings(szValue
, szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
));
478 if (dwValue
== 0 || dwValue
> (sizeof(szBuffer
) / sizeof(TCHAR
)))
485 _tcscpy(pLabelContext
->szValue
, szBuffer
);
486 else if (!bActiveProfile
)
487 _tcscpy(pLabelContext
->szValue
, szBuffer
);
494 ImportSoundEntry(HWND hwndDlg
, HKEY hKey
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP pAppMap
)
501 TCHAR szProfile
[MAX_PATH
];
504 if (RegOpenKeyEx(hKey
,
508 &hSubKey
) != ERROR_SUCCESS
)
512 pLabel
= FindLabel(pAppMap
, szLabelName
);
517 pLabel
->AppMap
= pAppMap
;
518 pLabel
->Next
= pAppMap
->LabelMap
;
519 pAppMap
->LabelMap
= pLabel
;
525 dwProfile
= sizeof(szProfile
) / sizeof(TCHAR
);
526 dwResult
= RegEnumKeyEx(hSubKey
,
535 if (dwResult
== ERROR_SUCCESS
)
537 if (ImportSoundLabel(hwndDlg
, hSubKey
, szProfile
, szLabelName
, szAppName
, pAppMap
, pLabel
))
544 }while(dwResult
== ERROR_SUCCESS
);
546 RegCloseKey(hSubKey
);
548 return dwNumProfiles
;
554 ImportAppProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szAppName
)
557 TCHAR szDefault
[MAX_PATH
];
563 TCHAR szName
[MAX_PATH
];
564 TCHAR szIcon
[MAX_PATH
];
567 //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
569 AppMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(APP_MAP
));
573 if (RegOpenKeyEx(hKey
,
577 &hSubKey
) != ERROR_SUCCESS
)
579 HeapFree(GetProcessHeap(), 0, AppMap
);
583 dwDefault
= sizeof(szDefault
) / sizeof(TCHAR
);
584 if (RegQueryValueEx(hSubKey
,
589 &dwDefault
) != ERROR_SUCCESS
)
591 RegCloseKey(hSubKey
);
592 HeapFree(GetProcessHeap(), 0, AppMap
);
596 dwDefault
= sizeof(szIcon
) / sizeof(TCHAR
);
597 if (RegQueryValueEx(hSubKey
,
602 &dwDefault
) != ERROR_SUCCESS
)
604 szIcon
[0] = _T('\0');
607 /* initialize app map */
608 _tcscpy(AppMap
->szName
, szAppName
);
609 _tcscpy(AppMap
->szDesc
, szDefault
);
610 _tcscpy(AppMap
->szIcon
, szIcon
);
612 AppMap
->Next
= s_App
;
620 dwName
= sizeof(szName
) / sizeof(TCHAR
);
621 dwResult
= RegEnumKeyEx(hSubKey
,
629 if (dwResult
== ERROR_SUCCESS
)
631 if (ImportSoundEntry(hwndDlg
, hSubKey
, szName
, szAppName
, AppMap
))
637 }while(dwResult
== ERROR_SUCCESS
);
638 RegCloseKey(hSubKey
);
643 ImportSoundProfiles(HWND hwndDlg
, HKEY hKey
)
648 TCHAR szName
[MAX_PATH
];
651 if (RegOpenKeyEx(hKey
,
655 &hSubKey
) != ERROR_SUCCESS
)
664 dwResult
= RegEnumKey(hSubKey
,
667 sizeof(szName
) / sizeof(TCHAR
));
669 if (dwResult
== ERROR_SUCCESS
)
671 if (ImportAppProfile(hwndDlg
, hSubKey
, szName
))
677 }while(dwResult
== ERROR_SUCCESS
);
678 RegCloseKey(hSubKey
);
680 return (dwNumApps
!= 0);
686 LoadSoundProfiles(HWND hwndDlg
)
691 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
692 _T("AppEvents\\Schemes"),
695 &hSubKey
) != ERROR_SUCCESS
)
700 dwNumSchemes
= EnumerateSoundProfiles(hwndDlg
, hSubKey
);
705 //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
706 ImportSoundProfiles(hwndDlg
, hSubKey
);
708 RegCloseKey(hSubKey
);
712 LoadSoundFiles(HWND hwndDlg
)
714 WCHAR szPath
[MAX_PATH
];
716 WIN32_FIND_DATAW FileData
;
721 /* Add no sound listview item */
722 if (LoadString(hApplet
, IDS_NO_SOUND
, szPath
, MAX_PATH
))
724 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
725 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szPath
);
728 /* Load sound files */
729 length
= GetWindowsDirectoryW(szPath
, MAX_PATH
);
730 if (length
== 0 || length
>= MAX_PATH
- 9)
734 if (szPath
[length
-1] != L
'\\')
736 szPath
[length
] = L
'\\';
739 wcscpy(&szPath
[length
], L
"media\\*");
742 hFile
= FindFirstFileW(szPath
, &FileData
);
743 if (hFile
== INVALID_HANDLE_VALUE
)
750 if (FileData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
753 ptr
= wcsrchr(FileData
.cFileName
, L
'\\');
760 ptr
= FileData
.cFileName
;
762 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
763 if (lResult
!= CB_ERR
)
765 wcscpy(&szPath
[length
-1], FileData
.cFileName
);
766 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(szPath
));
768 }while(FindNextFileW(hFile
, &FileData
) != 0);
777 ShowSoundScheme(HWND hwndDlg
)
780 PSOUND_SCHEME_CONTEXT pScheme
;
784 HWND hDlgCtrl
, hList
;
787 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
788 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
790 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
791 if (lIndex
== CB_ERR
)
796 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
797 if (lIndex
== CB_ERR
)
801 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
803 _tcscpy(szDefault
, pScheme
->szName
);
805 /* add column for app */
806 GetClientRect(hList
, &rect
);
807 ZeroMemory(&dummy
, sizeof(LV_COLUMN
));
808 dummy
.mask
= LVCF_WIDTH
;
810 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
811 (void)ListView_InsertColumn(hList
, 0, &dummy
);
817 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
820 ZeroMemory(&listItem
, sizeof(LV_ITEM
));
821 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
822 listItem
.pszText
= pLabelMap
->szDesc
;
823 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
824 listItem
.iItem
= ItemIndex
;
825 listItem
.iImage
= -1;
826 (void)ListView_InsertItem(hList
, &listItem
);
829 pLabelMap
= pLabelMap
->Next
;
831 pAppMap
= pAppMap
->Next
;
837 ApplyChanges(HWND hwndDlg
)
841 PSOUND_SCHEME_CONTEXT pScheme
;
843 PLABEL_CONTEXT pLabelContext
;
846 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
848 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
849 if (lIndex
== CB_ERR
)
854 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
855 if (lIndex
== CB_ERR
)
859 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
861 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
862 _T("AppEvents\\Schemes"),
865 &hKey
) != ERROR_SUCCESS
)
870 RegSetValueEx(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pScheme
->szName
, (_tcslen(pScheme
->szName
) +1) * sizeof(TCHAR
));
873 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
874 _T("AppEvents\\Schemes\\Apps"),
877 &hKey
) != ERROR_SUCCESS
)
882 pLabelContext
= pScheme
->LabelContext
;
886 _stprintf(Buffer
, _T("%s\\%s\\.Current"), pLabelContext
->AppMap
->szName
, pLabelContext
->LabelMap
->szName
);
888 if (RegOpenKeyEx(hKey
, Buffer
, 0, KEY_WRITE
, &hSubKey
) == ERROR_SUCCESS
)
890 RegSetValueEx(hSubKey
, NULL
, 0, REG_EXPAND_SZ
, (LPBYTE
)pLabelContext
->szValue
, (_tcslen(pLabelContext
->szValue
) +1) * sizeof(TCHAR
));
891 RegCloseKey(hSubKey
);
894 pLabelContext
= pLabelContext
->Next
;
898 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, (LONG
)PSNRET_NOERROR
);
903 /* Sounds property page dialog callback */
906 SoundsDlgProc(HWND hwndDlg
,
915 UINT NumWavOut
= waveOutGetNumDevs();
917 SendMessage(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
),
918 BM_SETIMAGE
,(WPARAM
)IMAGE_ICON
,
919 (LPARAM
)(HANDLE
)LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_PLAY_ICON
)));
922 LoadSoundProfiles(hwndDlg
);
923 LoadSoundFiles(hwndDlg
);
924 ShowSoundScheme(hwndDlg
);
928 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), FALSE
);
929 EnableWindow(GetDlgItem(hwndDlg
, IDC_SAVEAS_BTN
), FALSE
);
930 EnableWindow(GetDlgItem(hwndDlg
, IDC_DELETE_BTN
), FALSE
);
931 EnableWindow(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), FALSE
);
934 if (wParam
== (WPARAM
)GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
))
936 SetFocus(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
941 switch(LOWORD(wParam
))
946 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
947 if (lIndex
== CB_ERR
)
952 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
953 if (lIndex
!= CB_ERR
)
955 PlaySound((TCHAR
*)lIndex
, NULL
, SND_FILENAME
);
959 case IDC_SOUND_SCHEME
:
961 if (HIWORD(wParam
) == CBN_SELENDOK
)
963 (void)ListView_DeleteAllItems(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
964 ShowSoundScheme(hwndDlg
);
965 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), FALSE
);
966 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), FALSE
);
967 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
968 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), FALSE
);
969 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
975 if (HIWORD(wParam
) == CBN_SELENDOK
)
977 PLABEL_CONTEXT pLabelContext
;
981 SelCount
= ListView_GetSelectionMark(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
986 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
987 if (lIndex
== CB_ERR
)
991 ZeroMemory(&item
, sizeof(LVITEM
));
992 item
.mask
= LVIF_PARAM
;
993 item
.iItem
= SelCount
;
994 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
997 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
999 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1000 if (lResult
== CB_ERR
|| lResult
== 0)
1002 if (lIndex
!= pLabelContext
->szValue
[0])
1003 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1005 pLabelContext
->szValue
[0] = L
'\0';
1009 if (_tcsicmp(pLabelContext
->szValue
, (TCHAR
*)lResult
) || (lIndex
!= pLabelContext
->szValue
[0]))
1011 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1013 /// should store in current member
1015 _tcscpy(pLabelContext
->szValue
, (TCHAR
*)lResult
);
1017 if (_tcslen((TCHAR
*)lResult
) && lIndex
!= 0)
1019 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1023 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1035 PLABEL_CONTEXT pLabelContext
;
1039 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1040 lppsn
= (LPPSHNOTIFY
) lParam
;
1046 ApplyChanges(hwndDlg
);
1049 case LVN_ITEMCHANGED
:
1051 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1053 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1057 ZeroMemory(&item
, sizeof(LVITEM
));
1058 item
.mask
= LVIF_PARAM
;
1059 item
.iItem
= nm
->iItem
;
1061 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1063 LRESULT lCount
, lIndex
, lResult
;
1064 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1069 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1070 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1071 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1072 if (_tcslen(pLabelContext
->szValue
) == 0)
1074 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1075 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1079 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1080 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
1081 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1083 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1084 if (lResult
== CB_ERR
|| lResult
== 0)
1087 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1089 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);
1093 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1100 ptr
= pLabelContext
->szValue
;
1102 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
1103 if (lIndex
!= CB_ERR
)
1105 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)_tcsdup(pLabelContext
->szValue
));
1106 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);