1 /* $Id: main.c 12852 2005-01-06 13:58:04Z mf $
3 * PROJECT: ReactOS Multimedia Control Panel
4 * FILE: dll/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
))
69 pMap
= pAppMap
->LabelMap
;
75 if (!_tcscmp(pMap
->szName
, szName
))
81 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
85 pMap
->szName
= pMap
->szDesc
= _tcsdup(szName
);
88 HeapFree(GetProcessHeap(), 0, pMap
);
92 pMap
->AppMap
= pAppMap
;
100 VOID
RemoveLabel(PLABEL_MAP pMap
)
102 PLABEL_MAP pCurMap
= s_Map
;
112 if (pCurMap
->Next
== pMap
)
114 pCurMap
->Next
= pCurMap
->Next
->Next
;
117 pCurMap
= pCurMap
->Next
;
122 PAPP_MAP
FindApp(TCHAR
* szName
)
124 PAPP_MAP pMap
= s_App
;
128 if (!_tcscmp(pMap
->szName
, szName
))
138 PLABEL_CONTEXT
FindLabelContext(PSOUND_SCHEME_CONTEXT pSoundScheme
, TCHAR
* AppName
, TCHAR
* LabelName
)
140 PLABEL_CONTEXT pLabelContext
;
142 pLabelContext
= pSoundScheme
->LabelContext
;
144 while (pLabelContext
)
146 ASSERT(pLabelContext
->AppMap
);
147 ASSERT(pLabelContext
->LabelMap
);
149 if (!_tcsicmp(pLabelContext
->AppMap
->szName
, AppName
) && !_tcsicmp(pLabelContext
->LabelMap
->szName
, LabelName
))
151 return pLabelContext
;
153 pLabelContext
= pLabelContext
->Next
;
156 pLabelContext
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_CONTEXT
));
160 pLabelContext
->AppMap
= FindApp(AppName
);
161 pLabelContext
->LabelMap
= FindLabel(pLabelContext
->AppMap
, LabelName
);
162 ASSERT(pLabelContext
->AppMap
);
163 ASSERT(pLabelContext
->LabelMap
);
164 pLabelContext
->szValue
[0] = _T('\0');
165 pLabelContext
->Next
= pSoundScheme
->LabelContext
;
166 pSoundScheme
->LabelContext
= pLabelContext
;
168 return pLabelContext
;
173 LoadEventLabel(HKEY hKey
, TCHAR
* szSubKey
)
178 TCHAR szDesc
[MAX_PATH
];
179 TCHAR szData
[MAX_PATH
];
182 if (RegOpenKeyEx(hKey
,
186 &hSubKey
) != ERROR_SUCCESS
)
191 dwDesc
= sizeof(szDesc
) / sizeof(TCHAR
);
192 if (RegQueryValueEx(hSubKey
,
197 &dwDesc
) != ERROR_SUCCESS
)
199 RegCloseKey(hSubKey
);
203 dwData
= sizeof(szDesc
) / sizeof(TCHAR
);
204 if (RegQueryValueEx(hSubKey
,
209 &dwData
) != ERROR_SUCCESS
)
211 RegCloseKey(hSubKey
);
215 pMap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LABEL_MAP
));
220 pMap
->szName
= _tcsdup(szSubKey
);
221 pMap
->szDesc
= _tcsdup(szDesc
);
222 pMap
->szIcon
= _tcsdup(szData
);
243 TCHAR szName
[MAX_PATH
];
247 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
248 _T("AppEvents\\EventLabels"),
251 &hSubKey
) != ERROR_SUCCESS
)
260 dwName
= sizeof(szName
) / sizeof(szName
[0]);
261 dwResult
= RegEnumKeyEx(hSubKey
,
270 if (dwResult
== ERROR_SUCCESS
)
272 if (LoadEventLabel(hSubKey
, szName
))
279 } while (dwResult
== ERROR_SUCCESS
);
281 RegCloseKey(hSubKey
);
282 return (dwCount
!= 0);
287 AddSoundProfile(HWND hwndDlg
, HKEY hKey
, TCHAR
* szSubKey
, BOOL SetDefault
)
290 TCHAR szValue
[MAX_PATH
];
291 DWORD dwValue
, dwResult
;
293 if (RegOpenKeyEx(hKey
,
297 &hSubKey
) != ERROR_SUCCESS
)
302 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
303 dwResult
= RegQueryValueEx(hSubKey
,
309 RegCloseKey(hSubKey
);
310 if (dwResult
== ERROR_SUCCESS
)
312 LRESULT lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szValue
);
313 if (lResult
!= CB_ERR
)
315 PSOUND_SCHEME_CONTEXT pScheme
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(SOUND_SCHEME_CONTEXT
));
318 _tcscpy(pScheme
->szDesc
, szValue
);
319 _tcscpy(pScheme
->szName
, szSubKey
);
322 SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_SETITEMDATA
, (WPARAM
)lResult
, (LPARAM
)pScheme
);
325 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
);
393 PSOUND_SCHEME_CONTEXT
FindSoundProfile(HWND hwndDlg
, TCHAR
* szName
)
395 LRESULT lCount
, lIndex
, lResult
;
396 PSOUND_SCHEME_CONTEXT pScheme
;
398 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
399 if (lCount
== CB_ERR
)
404 for(lIndex
= 0; lIndex
< lCount
; lIndex
++)
406 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_SCHEME
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
407 if (lResult
== CB_ERR
)
412 pScheme
= (PSOUND_SCHEME_CONTEXT
)lResult
;
413 if (!_tcsicmp(pScheme
->szName
, szName
))
423 ImportSoundLabel(HWND hwndDlg
, HKEY hKey
, TCHAR
* szProfile
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP AppMap
, PLABEL_MAP LabelMap
)
426 TCHAR szValue
[MAX_PATH
];
427 TCHAR szBuffer
[MAX_PATH
];
429 PSOUND_SCHEME_CONTEXT pScheme
;
430 PLABEL_CONTEXT pLabelContext
;
431 BOOL bCurrentProfile
, bActiveProfile
;
433 //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
435 bCurrentProfile
= !_tcsicmp(szProfile
, _T(".Current"));
436 bActiveProfile
= !_tcsicmp(szProfile
, szDefault
);
438 if (RegOpenKeyEx(hKey
,
442 &hSubKey
) != ERROR_SUCCESS
)
447 dwValue
= sizeof(szValue
) / sizeof(TCHAR
);
448 if (RegQueryValueEx(hSubKey
,
453 &dwValue
) != ERROR_SUCCESS
)
459 pScheme
= FindSoundProfile(hwndDlg
, szDefault
);
461 pScheme
= FindSoundProfile(hwndDlg
, szProfile
);
465 //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
468 pLabelContext
= FindLabelContext(pScheme
, AppMap
->szName
, LabelMap
->szName
);
470 dwValue
= ExpandEnvironmentStrings(szValue
, szBuffer
, sizeof(szBuffer
) / sizeof(TCHAR
));
471 if (dwValue
== 0 || dwValue
> (sizeof(szBuffer
) / sizeof(TCHAR
)))
478 _tcscpy(pLabelContext
->szValue
, szBuffer
);
479 else if (!bActiveProfile
)
480 _tcscpy(pLabelContext
->szValue
, szBuffer
);
487 ImportSoundEntry(HWND hwndDlg
, HKEY hKey
, TCHAR
* szLabelName
, TCHAR
* szAppName
, PAPP_MAP pAppMap
)
494 TCHAR szProfile
[MAX_PATH
];
497 if (RegOpenKeyEx(hKey
,
501 &hSubKey
) != ERROR_SUCCESS
)
505 pLabel
= FindLabel(pAppMap
, szLabelName
);
510 pLabel
->AppMap
= pAppMap
;
511 pLabel
->Next
= pAppMap
->LabelMap
;
512 pAppMap
->LabelMap
= pLabel
;
518 dwProfile
= sizeof(szProfile
) / sizeof(TCHAR
);
519 dwResult
= RegEnumKeyEx(hSubKey
,
528 if (dwResult
== ERROR_SUCCESS
)
530 if (ImportSoundLabel(hwndDlg
, hSubKey
, szProfile
, szLabelName
, szAppName
, pAppMap
, pLabel
))
537 } while (dwResult
== ERROR_SUCCESS
);
539 RegCloseKey(hSubKey
);
541 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
);
631 RegCloseKey(hSubKey
);
637 ImportSoundProfiles(HWND hwndDlg
, HKEY hKey
)
642 TCHAR szName
[MAX_PATH
];
645 if (RegOpenKeyEx(hKey
,
649 &hSubKey
) != ERROR_SUCCESS
)
658 dwResult
= RegEnumKey(hSubKey
,
661 sizeof(szName
) / sizeof(TCHAR
));
663 if (dwResult
== ERROR_SUCCESS
)
665 if (ImportAppProfile(hwndDlg
, hSubKey
, szName
))
671 } while (dwResult
== ERROR_SUCCESS
);
673 RegCloseKey(hSubKey
);
675 return (dwNumApps
!= 0);
680 LoadSoundProfiles(HWND hwndDlg
)
685 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
686 _T("AppEvents\\Schemes"),
689 &hSubKey
) != ERROR_SUCCESS
)
694 dwNumSchemes
= EnumerateSoundProfiles(hwndDlg
, hSubKey
);
699 //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
700 ImportSoundProfiles(hwndDlg
, hSubKey
);
703 RegCloseKey(hSubKey
);
709 LoadSoundFiles(HWND hwndDlg
)
711 WCHAR szPath
[MAX_PATH
];
713 WIN32_FIND_DATAW FileData
;
718 /* Add no sound listview item */
719 if (LoadString(hApplet
, IDS_NO_SOUND
, szPath
, MAX_PATH
))
721 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
722 SendDlgItemMessageW(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szPath
);
725 /* Load sound files */
726 length
= GetWindowsDirectoryW(szPath
, MAX_PATH
);
727 if (length
== 0 || length
>= MAX_PATH
- 9)
731 if (szPath
[length
-1] != L
'\\')
733 szPath
[length
] = L
'\\';
736 wcscpy(&szPath
[length
], L
"media\\*");
739 hFile
= FindFirstFileW(szPath
, &FileData
);
740 if (hFile
== INVALID_HANDLE_VALUE
)
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);
773 ShowSoundScheme(HWND hwndDlg
)
776 PSOUND_SCHEME_CONTEXT pScheme
;
780 HWND hDlgCtrl
, hList
;
783 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_SOUND_SCHEME
);
784 hList
= GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
);
786 lIndex
= SendMessage(hDlgCtrl
, CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
787 if (lIndex
== CB_ERR
)
792 lIndex
= SendMessage(hDlgCtrl
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
793 if (lIndex
== CB_ERR
)
797 pScheme
= (PSOUND_SCHEME_CONTEXT
)lIndex
;
799 _tcscpy(szDefault
, pScheme
->szName
);
801 /* add column for app */
802 GetClientRect(hList
, &rect
);
803 ZeroMemory(&dummy
, sizeof(LV_COLUMN
));
804 dummy
.mask
= LVCF_WIDTH
;
806 dummy
.cx
= rect
.right
- rect
.left
- GetSystemMetrics(SM_CXVSCROLL
);
807 (void)ListView_InsertColumn(hList
, 0, &dummy
);
813 PLABEL_MAP pLabelMap
= pAppMap
->LabelMap
;
816 ZeroMemory(&listItem
, sizeof(LV_ITEM
));
817 listItem
.mask
= LVIF_TEXT
| LVIF_PARAM
| LVIF_IMAGE
;
818 listItem
.pszText
= pLabelMap
->szDesc
;
819 listItem
.lParam
= (LPARAM
)FindLabelContext(pScheme
, pAppMap
->szName
, pLabelMap
->szName
);
820 listItem
.iItem
= ItemIndex
;
821 listItem
.iImage
= -1;
822 (void)ListView_InsertItem(hList
, &listItem
);
825 pLabelMap
= pLabelMap
->Next
;
827 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
;
881 while (pLabelContext
)
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
;
1035 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
1041 ApplyChanges(hwndDlg
);
1044 case LVN_ITEMCHANGED
:
1046 LPNMLISTVIEW nm
= (LPNMLISTVIEW
)lParam
;
1048 if ((nm
->uNewState
& LVIS_SELECTED
) == 0)
1052 ZeroMemory(&item
, sizeof(LVITEM
));
1053 item
.mask
= LVIF_PARAM
;
1054 item
.iItem
= nm
->iItem
;
1056 if (ListView_GetItem(GetDlgItem(hwndDlg
, IDC_SCHEME_LIST
), &item
))
1058 LRESULT lCount
, lIndex
, lResult
;
1059 pLabelContext
= (PLABEL_CONTEXT
)item
.lParam
;
1064 EnableWindow(GetDlgItem(hwndDlg
, IDC_SOUND_LIST
), TRUE
);
1065 EnableWindow(GetDlgItem(hwndDlg
, IDC_TEXT_SOUND
), TRUE
);
1066 EnableWindow(GetDlgItem(hwndDlg
, IDC_BROWSE_SOUND
), TRUE
);
1067 if (_tcslen(pLabelContext
->szValue
) == 0)
1069 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
1070 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), FALSE
);
1074 EnableWindow(GetDlgItem(hwndDlg
, IDC_PLAY_SOUND
), TRUE
);
1075 lCount
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETCOUNT
, (WPARAM
)0, (LPARAM
)0);
1076 for (lIndex
= 0; lIndex
< lCount
; lIndex
++)
1078 lResult
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_GETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)0);
1079 if (lResult
== CB_ERR
|| lResult
== 0)
1082 if (!_tcscmp((TCHAR
*)lResult
, pLabelContext
->szValue
))
1084 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);
1088 ptr
= _tcsrchr(pLabelContext
->szValue
, _T('\\'));
1095 ptr
= pLabelContext
->szValue
;
1097 lIndex
= SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)ptr
);
1098 if (lIndex
!= CB_ERR
)
1100 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETITEMDATA
, (WPARAM
)lIndex
, (LPARAM
)_tcsdup(pLabelContext
->szValue
));
1101 SendDlgItemMessage(hwndDlg
, IDC_SOUND_LIST
, CB_SETCURSEL
, (WPARAM
)lIndex
, (LPARAM
)0);