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 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
)
739 if (LoadString(hApplet
, IDS_NO_SOUND
, szPath
, MAX_PATH
))
741 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
742 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szPath
);
747 if (FileData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
750 ptr
= wcsrchr(FileData
.cFileName
, L
'\\');
757 ptr
= FileData
.cFileName
;
759 lResult
= SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
760 if (lResult
!= CB_ERR
)
762 wcscpy(&szPath
[length
-1], FileData
.cFileName
);
763 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)_wcsdup(szPath
));
765 }while(FindNextFileW(hFile
, &FileData
) != 0);
774 ShowSoundScheme(HWND hwndDlg
)
777 PSOUND_SCHEME_CONTEXT pScheme
;
781 HWND hDlgCtrl
, hList
;
784 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
785 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
787 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
788 if (lIndex
== CB_ERR
)
793 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
794 if (lIndex
== CB_ERR
)
798 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
800 _tcscpy(szDefault
, pScheme
->szName
);
802 /* add column for app */
803 GetClientRect(hList
, &rect
);
804 ZeroMemory(&dummy
, sizeof(LV_COLUMN
));
805 dummy
.mask
= LVCF_WIDTH
;
807 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
808 (void)ListView_InsertColumn(hList
, 0, &dummy
);
814 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
817 ZeroMemory(&listItem
, sizeof(LV_ITEM
));
818 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
819 listItem
.pszText
= pLabelMap
->szDesc
;
820 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
821 listItem
.iItem
= ItemIndex
;
822 listItem
.iImage
= -1;
823 (void)ListView_InsertItem(hList
, &listItem
);
826 pLabelMap
= pLabelMap
->Next
;
828 pAppMap
= pAppMap
->Next
;
834 ApplyChanges(HWND hwndDlg
)
838 PSOUND_SCHEME_CONTEXT pScheme
;
840 PLABEL_CONTEXT pLabelContext
;
843 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
845 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
846 if (lIndex
== CB_ERR
)
851 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
852 if (lIndex
== CB_ERR
)
856 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
858 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
859 _T("AppEvents\\Schemes"),
862 &hKey
) != ERROR_SUCCESS
)
867 RegSetValueEx(hKey
, NULL
, 0, REG_SZ
, (LPBYTE
)pScheme
->szName
, (_tcslen(pScheme
->szName
) +1) * sizeof(TCHAR
));
870 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
871 _T("AppEvents\\Schemes\\Apps"),
874 &hKey
) != ERROR_SUCCESS
)
879 pLabelContext
= pScheme
->LabelContext
;
883 _stprintf(Buffer
, _T("%s\\%s\\.Current"), pLabelContext
->AppMap
->szName
, pLabelContext
->LabelMap
->szName
);
885 if (RegOpenKeyEx(hKey
, Buffer
, 0, KEY_WRITE
, &hSubKey
) == ERROR_SUCCESS
)
887 RegSetValueEx(hSubKey
, NULL
, 0, REG_EXPAND_SZ
, (LPBYTE
)pLabelContext
->szValue
, (_tcslen(pLabelContext
->szValue
) +1) * sizeof(TCHAR
));
888 RegCloseKey(hSubKey
);
891 pLabelContext
= pLabelContext
->Next
;
895 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, (LONG
)PSNRET_NOERROR
);
900 /* Sounds property page dialog callback */
903 SoundsDlgProc(HWND hwndDlg
,
912 UINT NumWavOut
= waveOutGetNumDevs();
914 SendMessage(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
),
915 BM_SETIMAGE
,(WPARAM
)IMAGE_ICON
,
916 (LPARAM
)(HANDLE
)LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_PLAY_ICON
)));
919 LoadSoundProfiles(hwndDlg
);
920 LoadSoundFiles(hwndDlg
);
921 ShowSoundScheme(hwndDlg
);
925 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
), FALSE
);
926 EnableWindow(GetDlgItem(hwndDlg
, IDC_SAVEAS_BTN
), FALSE
);
927 EnableWindow(GetDlgItem(hwndDlg
, IDC_DELETE_BTN
), FALSE
);
928 EnableWindow(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), FALSE
);
931 if (wParam
== (WPARAM
)GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
))
933 SetFocus(GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
));
938 switch(LOWORD(wParam
))
943 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
944 if (lIndex
== CB_ERR
)
949 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
950 if (lIndex
!= CB_ERR
)
952 PlaySound((TCHAR
*)lIndex
, NULL
, SND_FILENAME
);
956 case IDC_SOUND_SCHEME
:
958 if (HIWORD(wParam
) == CBN_SELENDOK
)
960 (void)ListView_DeleteAllItems(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
961 ShowSoundScheme(hwndDlg
);
962 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), FALSE
);
963 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), FALSE
);
964 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
965 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), FALSE
);
966 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
972 if (HIWORD(wParam
) == CBN_SELENDOK
)
974 PLABEL_CONTEXT pLabelContext
;
978 SelCount
= ListView_GetSelectionMark(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
));
983 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
984 if (lIndex
== CB_ERR
)
988 ZeroMemory(&item
, sizeof(LVITEM
));
989 item
.mask
= LVIF_PARAM
;
990 item
.iItem
= SelCount
;
991 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
994 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
996 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
997 if (lResult
== CB_ERR
|| lResult
== 0)
999 if (lIndex
!= pLabelContext
->szValue
[0])
1000 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1002 pLabelContext
->szValue
[0] = L
'\0';
1006 if (_tcsicmp(pLabelContext
->szValue
, (TCHAR
*)lResult
) || (lIndex
!= pLabelContext
->szValue
[0]))
1008 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
1010 /// should store in current member
1012 _tcscpy(pLabelContext
->szValue
, (TCHAR
*)lResult
);
1014 if (_tcslen((TCHAR
*)lResult
) && lIndex
!= 0)
1016 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1020 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1032 PLABEL_CONTEXT pLabelContext
;
1036 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1037 lppsn
= (LPPSHNOTIFY
) lParam
;
1043 ApplyChanges(hwndDlg
);
1046 case LVN_ITEMCHANGED
:
1048 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1050 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1054 ZeroMemory(&item
, sizeof(LVITEM
));
1055 item
.mask
= LVIF_PARAM
;
1056 item
.iItem
= nm
->iItem
;
1057 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1059 LRESULT lCount
, lIndex
, lResult
;
1060 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1065 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1066 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1067 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1068 if (_tcslen(pLabelContext
->szValue
) == 0)
1070 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1071 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1075 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1076 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
1077 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1079 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1080 if (lResult
== CB_ERR
|| lResult
== 0)
1083 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1085 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);
1089 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1096 ptr
= pLabelContext
->szValue
;
1098 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
1099 if (lIndex
!= CB_ERR
)
1101 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)_tcsdup(pLabelContext
->szValue
));
1102 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);