ReactOS  0.4.13-dev-241-g63286c6
sounds.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Multimedia Control Panel
3  * FILE: dll/cpl/mmsys/sounds.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>
8  * Victor Martinez Calvo <victor.martinez@reactos.org>
9  * Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
10  */
11 
12 #include "mmsys.h"
13 
14 #include <commdlg.h>
15 #include <windowsx.h>
16 #include <strsafe.h>
17 
18 #include <debug.h>
19 
20 typedef struct _LABEL_MAP
21 {
25  struct _APP_MAP *AppMap;
26  struct _LABEL_MAP *Next;
28 
29 typedef struct _APP_MAP
30 {
34 
35  struct _APP_MAP *Next;
37 } APP_MAP, *PAPP_MAP;
38 
39 typedef struct _LABEL_CONTEXT
40 {
46 
47 typedef struct _SOUND_SCHEME_CONTEXT
48 {
53 
54 typedef struct _GLOBAL_DATA
55 {
62 
63 
64 /* A filter string is a list separated by NULL and ends with double NULLs. */
66 {
67  WCHAR *pch;
68 
69  ASSERT(psz[0] != UNICODE_NULL &&
70  psz[wcslen(psz) - 1] == L'|');
71  for (pch = psz; *pch != UNICODE_NULL; pch++)
72  {
73  /* replace vertical bar with NULL */
74  if (*pch == L'|')
75  {
76  *pch = UNICODE_NULL;
77  }
78  }
79  return psz;
80 }
81 
83 {
84  PLABEL_MAP pMap = pGlobalData->pLabelMap;
85 
86  while (pMap)
87  {
88  ASSERT(pMap);
89  ASSERT(pMap->szName);
90  if (!_tcscmp(pMap->szName, szName))
91  return pMap;
92 
93  pMap = pMap->Next;
94  }
95 
96  pMap = pAppMap->LabelMap;
97 
98  while (pMap)
99  {
100  ASSERT(pMap);
101  ASSERT(pMap->szName);
102  if (!_tcscmp(pMap->szName, szName))
103  return pMap;
104 
105  pMap = pMap->Next;
106  }
107 
109  if (!pMap)
110  return NULL;
111 
112  pMap->szName = pMap->szDesc = _tcsdup(szName);
113  if (!pMap->szName)
114  {
115  HeapFree(GetProcessHeap(), 0, pMap);
116  return NULL;
117  }
118 
119  pMap->AppMap = pAppMap;
120  pMap->Next = pGlobalData->pLabelMap;
121  pGlobalData->pLabelMap = pMap;
122 
123  return pMap;
124 }
125 
126 
128 {
129  PLABEL_MAP pCurMap = pGlobalData->pLabelMap;
130 
131  if (pCurMap == pMap)
132  {
133  pGlobalData->pLabelMap = pGlobalData->pLabelMap->Next;
134  return;
135  }
136 
137  while (pCurMap)
138  {
139  if (pCurMap->Next == pMap)
140  {
141  pCurMap->Next = pCurMap->Next->Next;
142  return;
143  }
144  pCurMap = pCurMap->Next;
145  }
146 }
147 
148 static
149 VOID
151 {
152  PLABEL_MAP pCurMap;
153 
154  while (pGlobalData->pLabelMap)
155  {
156  pCurMap = pGlobalData->pLabelMap->Next;
157  HeapFree(GetProcessHeap(), 0, pGlobalData->pLabelMap);
158  pGlobalData->pLabelMap = pCurMap;
159  }
160 }
161 
163 {
164  PAPP_MAP pMap = pGlobalData->pAppMap;
165 
166  while (pMap)
167  {
168  if (!_tcscmp(pMap->szName, szName))
169  return pMap;
170 
171  pMap = pMap->Next;
172 
173  }
174  return NULL;
175 }
176 
177 static
178 VOID
180 {
181  PAPP_MAP pCurMap;
182 
183  while (pGlobalData->pAppMap)
184  {
185  pCurMap = pGlobalData->pAppMap->Next;
186  HeapFree(GetProcessHeap(), 0, pGlobalData->pAppMap);
187  pGlobalData->pAppMap = pCurMap;
188  }
189 }
190 
192 {
193  PLABEL_CONTEXT pLabelContext;
194 
195  pLabelContext = pSoundScheme->LabelContext;
196 
197  while (pLabelContext)
198  {
199  ASSERT(pLabelContext->AppMap);
200  ASSERT(pLabelContext->LabelMap);
201 
202  if (!_tcsicmp(pLabelContext->AppMap->szName, AppName) && !_tcsicmp(pLabelContext->LabelMap->szName, LabelName))
203  {
204  return pLabelContext;
205  }
206  pLabelContext = pLabelContext->Next;
207  }
208 
209  pLabelContext = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LABEL_CONTEXT));
210  if (!pLabelContext)
211  return NULL;
212 
213  pLabelContext->AppMap = FindApp(pGlobalData, AppName);
214  pLabelContext->LabelMap = FindLabel(pGlobalData, pLabelContext->AppMap, LabelName);
215  ASSERT(pLabelContext->AppMap);
216  ASSERT(pLabelContext->LabelMap);
217  pLabelContext->szValue[0] = _T('\0');
218  pLabelContext->Next = pSoundScheme->LabelContext;
219  pSoundScheme->LabelContext = pLabelContext;
220 
221  return pLabelContext;
222 }
223 
224 
225 BOOL
226 LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, TCHAR * szSubKey)
227 {
228  HKEY hSubKey;
229  DWORD cbValue;
230  TCHAR szDesc[MAX_PATH];
232  PLABEL_MAP pMap;
233 
234  if (RegOpenKeyEx(hKey,
235  szSubKey,
236  0,
237  KEY_READ,
238  &hSubKey) != ERROR_SUCCESS)
239  {
240  return FALSE;
241  }
242 
243  cbValue = sizeof(szDesc);
244  if (RegQueryValueEx(hSubKey,
245  NULL,
246  NULL,
247  NULL,
248  (LPBYTE)szDesc,
249  &cbValue) != ERROR_SUCCESS)
250  {
251  RegCloseKey(hSubKey);
252  return FALSE;
253  }
254 
255  cbValue = sizeof(szData);
256  if (RegQueryValueEx(hSubKey,
257  _T("DispFileName"),
258  NULL,
259  NULL,
260  (LPBYTE)szData,
261  &cbValue) != ERROR_SUCCESS)
262  {
263  RegCloseKey(hSubKey);
264  return FALSE;
265  }
266 
268  if (!pMap)
269  {
270  return FALSE;
271  }
272 
273  pMap->szName = _tcsdup(szSubKey);
274  pMap->szDesc = _tcsdup(szDesc);
275  pMap->szIcon = _tcsdup(szData);
276 
277  if (pGlobalData->pLabelMap)
278  {
279  pMap->Next = pGlobalData->pLabelMap;
280  pGlobalData->pLabelMap = pMap;
281  }
282  else
283  {
284  pGlobalData->pLabelMap = pMap;
285  pGlobalData->pLabelMap->Next = NULL;
286  }
287  return TRUE;
288 }
289 
290 
291 BOOL
293 {
294  HKEY hSubKey;
295  DWORD dwCurKey;
297  DWORD dwName;
298  DWORD dwResult;
299  DWORD dwCount;
301  _T("AppEvents\\EventLabels"),
302  0,
303  KEY_READ,
304  &hSubKey) != ERROR_SUCCESS)
305  {
306  return FALSE;
307  }
308 
309  dwCurKey = 0;
310  dwCount = 0;
311  do
312  {
313  dwName = _countof(szName);
314  dwResult = RegEnumKeyEx(hSubKey,
315  dwCurKey,
316  szName,
317  &dwName,
318  NULL,
319  NULL,
320  NULL,
321  NULL);
322 
323  if (dwResult == ERROR_SUCCESS)
324  {
325  if (LoadEventLabel(pGlobalData, hSubKey, szName))
326  {
327  dwCount++;
328  }
329  }
330  dwCurKey++;
331 
332  } while (dwResult == ERROR_SUCCESS);
333 
334  RegCloseKey(hSubKey);
335  return (dwCount != 0);
336 }
337 
338 
339 BOOL
340 AddSoundProfile(HWND hwndDlg, HKEY hKey, TCHAR * szSubKey, BOOL SetDefault)
341 {
342  HKEY hSubKey;
343  TCHAR szValue[MAX_PATH];
344  DWORD cbValue, dwResult;
345  LRESULT lResult;
346  PSOUND_SCHEME_CONTEXT pScheme;
347 
348  if (RegOpenKeyEx(hKey,
349  szSubKey,
350  0,
351  KEY_READ,
352  &hSubKey) != ERROR_SUCCESS)
353  {
354  return FALSE;
355  }
356 
357  cbValue = sizeof(szValue);
358  dwResult = RegQueryValueEx(hSubKey,
359  NULL,
360  NULL,
361  NULL,
362  (LPBYTE)szValue,
363  &cbValue);
364  RegCloseKey(hSubKey);
365 
366  if (dwResult != ERROR_SUCCESS)
367  return FALSE;
368 
369  /* Try to add the new profile */
370  lResult = ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), szValue);
371  if (lResult == CB_ERR)
372  return FALSE;
373 
374  /* Allocate the profile scheme buffer */
376  if (pScheme == NULL)
377  {
378  /* We failed to allocate the buffer, no need to keep a dangling string in the combobox */
380  return FALSE;
381  }
382 
383  StringCchCopy(pScheme->szDesc, MAX_PATH, szValue);
384  StringCchCopy(pScheme->szName, MAX_PATH, szSubKey);
385 
386  /* Associate the value with the item in the combobox */
387  ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), lResult, pScheme);
388 
389  /* Optionally, select the profile */
390  if (SetDefault)
391  {
392  ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), lResult);
393  }
394 
395  return TRUE;
396 }
397 
398 
399 DWORD
400 EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
401 {
402  HKEY hSubKey;
403  DWORD dwName, dwCurKey, dwResult, dwNumSchemes;
404  DWORD cbDefault;
406 
407  cbDefault = sizeof(pGlobalData->szDefault);
408  if (RegQueryValueEx(hKey,
409  NULL,
410  NULL,
411  NULL,
412  (LPBYTE)pGlobalData->szDefault,
413  &cbDefault) != ERROR_SUCCESS)
414  {
415  return FALSE;
416  }
417 
418  if (RegOpenKeyEx(hKey,
419  _T("Names"),
420  0,
421  KEY_READ,
422  &hSubKey) != ERROR_SUCCESS)
423  {
424  return FALSE;
425  }
426 
427  dwNumSchemes = 0;
428  dwCurKey = 0;
429  do
430  {
431  dwName = _countof(szName);
432  dwResult = RegEnumKeyEx(hSubKey,
433  dwCurKey,
434  szName,
435  &dwName,
436  NULL,
437  NULL,
438  NULL,
439  NULL);
440 
441  if (dwResult == ERROR_SUCCESS)
442  {
443  if (AddSoundProfile(hwndDlg, hSubKey, szName, (!_tcsicmp(szName, pGlobalData->szDefault))))
444  {
445  dwNumSchemes++;
446  }
447  }
448 
449  dwCurKey++;
450  } while (dwResult == ERROR_SUCCESS);
451 
452  RegCloseKey(hSubKey);
453  return dwNumSchemes;
454 }
455 
456 
458 {
459  LRESULT lCount, lIndex, lResult;
460  PSOUND_SCHEME_CONTEXT pScheme;
461  HWND hwndComboBox;
462 
463  hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
464  lCount = ComboBox_GetCount(hwndComboBox);
465  if (lCount == CB_ERR)
466  {
467  return NULL;
468  }
469 
470  for (lIndex = 0; lIndex < lCount; lIndex++)
471  {
472  lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
473  if (lResult == CB_ERR)
474  {
475  continue;
476  }
477 
478  pScheme = (PSOUND_SCHEME_CONTEXT)lResult;
479  if (!_tcsicmp(pScheme->szName, szName))
480  {
481  return pScheme;
482  }
483  }
484  return NULL;
485 }
486 
487 static
488 VOID
490 {
491  LRESULT lCount, lIndex, lResult;
492  PSOUND_SCHEME_CONTEXT pScheme;
493  PLABEL_CONTEXT pLabelContext;
494  HWND hwndComboBox;
495 
496  hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
497  lCount = ComboBox_GetCount(hwndComboBox);
498  if (lCount == CB_ERR)
499  return;
500 
501  for (lIndex = 0; lIndex < lCount; lIndex++)
502  {
503  lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
504  if (lResult == CB_ERR)
505  {
506  continue;
507  }
508 
509  pScheme = (PSOUND_SCHEME_CONTEXT)lResult;
510 
511  while (pScheme->LabelContext)
512  {
513  pLabelContext = pScheme->LabelContext->Next;
514  HeapFree(GetProcessHeap(), 0, pScheme->LabelContext);
515  pScheme->LabelContext = pLabelContext;
516  }
517 
518  HeapFree(GetProcessHeap(), 0, pScheme);
519  }
520 }
521 
522 BOOL
523 ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR * szProfile, TCHAR * szLabelName, TCHAR * szAppName, PAPP_MAP AppMap, PLABEL_MAP LabelMap)
524 {
525  HKEY hSubKey;
526  TCHAR szValue[MAX_PATH];
527  TCHAR szBuffer[MAX_PATH];
528  DWORD cbValue, cchLength;
529  PSOUND_SCHEME_CONTEXT pScheme;
530  PLABEL_CONTEXT pLabelContext;
531  BOOL bCurrentProfile, bActiveProfile;
532 
533  //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
534 
535  bCurrentProfile = !_tcsicmp(szProfile, _T(".Current"));
536  bActiveProfile = !_tcsicmp(szProfile, pGlobalData->szDefault);
537 
538  if (RegOpenKeyEx(hKey,
539  szProfile,
540  0,
541  KEY_READ,
542  &hSubKey) != ERROR_SUCCESS)
543  {
544  return FALSE;
545  }
546 
547  cbValue = sizeof(szValue);
548  if (RegQueryValueEx(hSubKey,
549  NULL,
550  NULL,
551  NULL,
552  (LPBYTE)szValue,
553  &cbValue) != ERROR_SUCCESS)
554  {
555  return FALSE;
556  }
557 
558  if (bCurrentProfile)
559  pScheme = FindSoundProfile(hwndDlg, pGlobalData->szDefault);
560  else
561  pScheme = FindSoundProfile(hwndDlg, szProfile);
562 
563  if (!pScheme)
564  {
565  //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
566  return FALSE;
567  }
568  pLabelContext = FindLabelContext(pGlobalData, pScheme, AppMap->szName, LabelMap->szName);
569 
570  cchLength = ExpandEnvironmentStrings(szValue, szBuffer, _countof(szBuffer));
571  if (cchLength == 0 || cchLength > _countof(szBuffer))
572  {
573  /* fixme */
574  return FALSE;
575  }
576 
577  if (bCurrentProfile)
578  _tcscpy(pLabelContext->szValue, szBuffer);
579  else if (!bActiveProfile)
580  _tcscpy(pLabelContext->szValue, szBuffer);
581 
582  return TRUE;
583 }
584 
585 
586 DWORD
587 ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR * szLabelName, TCHAR * szAppName, PAPP_MAP pAppMap)
588 {
589  HKEY hSubKey;
590  DWORD dwNumProfiles;
591  DWORD dwCurKey;
592  DWORD dwResult;
593  DWORD dwProfile;
594  TCHAR szProfile[MAX_PATH];
595  PLABEL_MAP pLabel;
596 
597  if (RegOpenKeyEx(hKey,
598  szLabelName,
599  0,
600  KEY_READ,
601  &hSubKey) != ERROR_SUCCESS)
602  {
603  return FALSE;
604  }
605  pLabel = FindLabel(pGlobalData, pAppMap, szLabelName);
606 
607  ASSERT(pLabel);
608  RemoveLabel(pGlobalData, pLabel);
609 
610  pLabel->AppMap = pAppMap;
611  pLabel->Next = pAppMap->LabelMap;
612  pAppMap->LabelMap = pLabel;
613 
614  dwNumProfiles = 0;
615  dwCurKey = 0;
616  do
617  {
618  dwProfile = _countof(szProfile);
619  dwResult = RegEnumKeyEx(hSubKey,
620  dwCurKey,
621  szProfile,
622  &dwProfile,
623  NULL,
624  NULL,
625  NULL,
626  NULL);
627 
628  if (dwResult == ERROR_SUCCESS)
629  {
630  if (ImportSoundLabel(pGlobalData, hwndDlg, hSubKey, szProfile, szLabelName, szAppName, pAppMap, pLabel))
631  {
632  dwNumProfiles++;
633  }
634  }
635 
636  dwCurKey++;
637  } while (dwResult == ERROR_SUCCESS);
638 
639  RegCloseKey(hSubKey);
640 
641  return dwNumProfiles;
642 }
643 
644 
645 DWORD
646 ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR * szAppName)
647 {
648  HKEY hSubKey;
649  TCHAR szDefault[MAX_PATH];
650  DWORD cbValue;
651  DWORD dwCurKey;
652  DWORD dwResult;
653  DWORD dwNumEntry;
654  DWORD dwName;
657  PAPP_MAP AppMap;
658 
659  //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
660 
661  AppMap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APP_MAP));
662  if (!AppMap)
663  return 0;
664 
665  if (RegOpenKeyEx(hKey,
666  szAppName,
667  0,
668  KEY_READ,
669  &hSubKey) != ERROR_SUCCESS)
670  {
671  HeapFree(GetProcessHeap(), 0, AppMap);
672  return 0;
673  }
674 
675  cbValue = sizeof(szDefault);
676  if (RegQueryValueEx(hSubKey,
677  NULL,
678  NULL,
679  NULL,
680  (LPBYTE)szDefault,
681  &cbValue) != ERROR_SUCCESS)
682  {
683  RegCloseKey(hSubKey);
684  HeapFree(GetProcessHeap(), 0, AppMap);
685  return 0;
686  }
687 
688  cbValue = sizeof(szIcon);
689  if (RegQueryValueEx(hSubKey,
690  _T("DispFileName"),
691  NULL,
692  NULL,
693  (LPBYTE)szIcon,
694  &cbValue) != ERROR_SUCCESS)
695  {
696  szIcon[0] = _T('\0');
697  }
698 
699  /* initialize app map */
700  _tcscpy(AppMap->szName, szAppName);
701  _tcscpy(AppMap->szDesc, szDefault);
702  _tcscpy(AppMap->szIcon, szIcon);
703 
704  AppMap->Next = pGlobalData->pAppMap;
705  pGlobalData->pAppMap = AppMap;
706 
707 
708  dwCurKey = 0;
709  dwNumEntry = 0;
710  do
711  {
712  dwName = _countof(szName);
713  dwResult = RegEnumKeyEx(hSubKey,
714  dwCurKey,
715  szName,
716  &dwName,
717  NULL,
718  NULL,
719  NULL,
720  NULL);
721  if (dwResult == ERROR_SUCCESS)
722  {
723  if (ImportSoundEntry(pGlobalData, hwndDlg, hSubKey, szName, szAppName, AppMap))
724  {
725  dwNumEntry++;
726  }
727  }
728  dwCurKey++;
729  } while (dwResult == ERROR_SUCCESS);
730 
731  RegCloseKey(hSubKey);
732  return dwNumEntry;
733 }
734 
735 
736 BOOL
737 ImportSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
738 {
739  DWORD dwCurKey;
740  DWORD dwResult;
741  DWORD dwNumApps;
743  HKEY hSubKey;
744 
745  if (RegOpenKeyEx(hKey,
746  _T("Apps"),
747  0,
748  KEY_READ,
749  &hSubKey) != ERROR_SUCCESS)
750  {
751  return FALSE;
752  }
753 
754  dwNumApps = 0;
755  dwCurKey = 0;
756  do
757  {
758  dwResult = RegEnumKey(hSubKey,
759  dwCurKey,
760  szName,
761  _countof(szName));
762 
763  if (dwResult == ERROR_SUCCESS)
764  {
765  if (ImportAppProfile(pGlobalData, hwndDlg, hSubKey, szName))
766  {
767  dwNumApps++;
768  }
769  }
770  dwCurKey++;
771  } while (dwResult == ERROR_SUCCESS);
772 
773  RegCloseKey(hSubKey);
774 
775  return (dwNumApps != 0);
776 }
777 
778 
779 BOOL
780 LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
781 {
782  HKEY hSubKey;
783  DWORD dwNumSchemes;
784 
786  _T("AppEvents\\Schemes"),
787  0,
788  KEY_READ,
789  &hSubKey) != ERROR_SUCCESS)
790  {
791  return FALSE;
792  }
793 
794  dwNumSchemes = EnumerateSoundProfiles(pGlobalData, hwndDlg, hSubKey);
795 
796 
797  if (dwNumSchemes)
798  {
799  //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
800  ImportSoundProfiles(pGlobalData, hwndDlg, hSubKey);
801  }
802 
803  RegCloseKey(hSubKey);
804  return FALSE;
805 }
806 
807 
808 BOOL
810 {
811  TCHAR szList[256];
813  WCHAR * ptr;
815  HANDLE hFile;
816  LRESULT lResult;
817  UINT length;
818 
819  /* Add no sound listview item */
820  if (LoadString(hApplet, IDS_NO_SOUND, szList, _countof(szList)))
821  {
822  szList[_countof(szList) - 1] = TEXT('\0');
823  ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST), szList);
824  }
825 
826  /* Load sound files */
828  if (length == 0 || length >= MAX_PATH - 9)
829  {
830  return FALSE;
831  }
832  if (szPath[length-1] != L'\\')
833  {
834  szPath[length] = L'\\';
835  length++;
836  }
837  wcscpy(&szPath[length], L"media\\*");
838  length += 7;
839 
842  {
843  return FALSE;
844  }
845 
846  do
847  {
848  if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
849  continue;
850 
851  ptr = wcsrchr(FileData.cFileName, L'\\');
852  if (ptr)
853  {
854  ptr++;
855  }
856  else
857  {
858  ptr = FileData.cFileName;
859  }
860  lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0, (LPARAM)ptr);
861  if (lResult != CB_ERR)
862  {
863  wcscpy(&szPath[length-1], FileData.cFileName);
865  }
866  } while (FindNextFileW(hFile, &FileData) != 0);
867 
868  FindClose(hFile);
869  return TRUE;
870 }
871 
872 
873 BOOL
874 ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
875 {
876  LRESULT lIndex;
877  PSOUND_SCHEME_CONTEXT pScheme;
878  PAPP_MAP pAppMap;
879  PLABEL_MAP pLabelMap;
880  PLABEL_CONTEXT pLabelContext;
881  HWND hDlgCtrl, hList;
882  TVINSERTSTRUCT tvItem;
883  HTREEITEM hTreeItem;
884 
885  hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
886  hList = GetDlgItem(hwndDlg, IDC_SCHEME_LIST);
887 
888  if (pGlobalData->hSoundsImageList != NULL)
889  {
891  }
892 
893  lIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
894  if (lIndex == CB_ERR)
895  {
896  return FALSE;
897  }
898 
899  lIndex = SendMessage(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, (LPARAM)0);
900  if (lIndex == CB_ERR)
901  {
902  return FALSE;
903  }
904  pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
905 
906  _tcscpy(pGlobalData->szDefault, pScheme->szName);
907 
908  pAppMap = pGlobalData->pAppMap;
909  while (pAppMap)
910  {
911  ZeroMemory(&tvItem, sizeof(tvItem));
912  tvItem.hParent = TVI_ROOT;
913  tvItem.hInsertAfter = TVI_FIRST;
914 
915  tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
916  tvItem.item.state = TVIS_EXPANDED;
917  tvItem.item.stateMask = TVIS_EXPANDED;
918  tvItem.item.pszText = pAppMap->szDesc;
919  tvItem.item.iImage = IMAGE_SOUND_SECTION;
920  tvItem.item.iSelectedImage = IMAGE_SOUND_SECTION;
921  tvItem.item.lParam = (LPARAM)NULL;
922 
923  hTreeItem = TreeView_InsertItem(hList, &tvItem);
924 
925  pLabelMap = pAppMap->LabelMap;
926  while (pLabelMap)
927  {
928  pLabelContext = FindLabelContext(pGlobalData, pScheme, pAppMap->szName, pLabelMap->szName);
929 
930  ZeroMemory(&tvItem, sizeof(tvItem));
931  tvItem.hParent = hTreeItem;
932  tvItem.hInsertAfter = TVI_SORT;
933 
934  tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
935  tvItem.item.state = TVIS_EXPANDED;
936  tvItem.item.stateMask = TVIS_EXPANDED;
937  tvItem.item.pszText = pLabelMap->szDesc;
938  if (pLabelContext->szValue && _tcslen(pLabelContext->szValue) > 0)
939  {
940  tvItem.item.iImage = IMAGE_SOUND_ASSIGNED;
941  tvItem.item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
942  }
943  else
944  {
945  tvItem.item.iImage = IMAGE_SOUND_NONE;
946  tvItem.item.iSelectedImage = IMAGE_SOUND_NONE;
947  }
948  tvItem.item.lParam = (LPARAM)FindLabelContext(pGlobalData, pScheme, pAppMap->szName, pLabelMap->szName);
949 
950  TreeView_InsertItem(hList, &tvItem);
951 
952  pLabelMap = pLabelMap->Next;
953  }
954  pAppMap = pAppMap->Next;
955  }
956  return TRUE;
957 }
958 
959 
960 BOOL
962 {
963  HKEY hKey, hSubKey;
964  LRESULT lIndex;
965  PSOUND_SCHEME_CONTEXT pScheme;
966  HWND hDlgCtrl;
967  PLABEL_CONTEXT pLabelContext;
968  TCHAR Buffer[100];
969 
970  hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
971 
972  lIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
973  if (lIndex == CB_ERR)
974  {
975  return FALSE;
976  }
977 
978  lIndex = SendMessage(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, (LPARAM)0);
979  if (lIndex == CB_ERR)
980  {
981  return FALSE;
982  }
983  pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
984 
986  _T("AppEvents\\Schemes"),
987  0,
988  KEY_WRITE,
989  &hKey) != ERROR_SUCCESS)
990  {
991  return FALSE;
992  }
993 
994  RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)pScheme->szName, (_tcslen(pScheme->szName) +1) * sizeof(TCHAR));
995  RegCloseKey(hKey);
996 
998  _T("AppEvents\\Schemes\\Apps"),
999  0,
1000  KEY_WRITE,
1001  &hKey) != ERROR_SUCCESS)
1002  {
1003  return FALSE;
1004  }
1005 
1006  pLabelContext = pScheme->LabelContext;
1007 
1008  while (pLabelContext)
1009  {
1010  _stprintf(Buffer, _T("%s\\%s\\.Current"), pLabelContext->AppMap->szName, pLabelContext->LabelMap->szName);
1011 
1012  if (RegOpenKeyEx(hKey, Buffer, 0, KEY_WRITE, &hSubKey) == ERROR_SUCCESS)
1013  {
1014  RegSetValueEx(hSubKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)pLabelContext->szValue, (_tcslen(pLabelContext->szValue) +1) * sizeof(TCHAR));
1015  RegCloseKey(hSubKey);
1016  }
1017 
1018  pLabelContext = pLabelContext->Next;
1019  }
1020  RegCloseKey(hKey);
1021 
1023  return TRUE;
1024 }
1025 
1026 
1027 HIMAGELIST
1028 InitImageList(UINT StartResource,
1029  UINT EndResource,
1030  UINT Width,
1031  UINT Height,
1032  ULONG type)
1033 {
1034  HANDLE hImage;
1035  HIMAGELIST himl;
1036  UINT i;
1037  INT ret;
1038 
1039  /* Create the toolbar icon image list */
1040  himl = ImageList_Create(Width,
1041  Height,
1043  EndResource - StartResource,
1044  0);
1045  if (himl == NULL)
1046  return NULL;
1047 
1048  ret = 0;
1049  for (i = StartResource; i <= EndResource && ret != -1; i++)
1050  {
1051  hImage = LoadImageW(hApplet,
1053  type,
1054  Width,
1055  Height,
1057  if (hImage == NULL)
1058  {
1060  himl = NULL;
1061  break;
1062  }
1063 
1064  if (type == IMAGE_BITMAP)
1065  {
1067  hImage,
1068  RGB(255, 0, 128));
1069  }
1070  else if (type == IMAGE_ICON)
1071  {
1073  hImage);
1074  }
1075 
1076  DeleteObject(hImage);
1077  }
1078 
1079  if (ret == -1)
1080  {
1082  himl = NULL;
1083  }
1084 
1085  return himl;
1086 }
1087 
1088 
1089 /* Sounds property page dialog callback */
1090 INT_PTR
1091 CALLBACK
1093  UINT uMsg,
1094  WPARAM wParam,
1095  LPARAM lParam)
1096 {
1097  PGLOBAL_DATA pGlobalData;
1098 
1101  WCHAR szFilter[256], szTitle[256];
1102  LPWSTR pFileName;
1103  LRESULT lResult;
1104 
1105  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
1106 
1107  switch (uMsg)
1108  {
1109  case WM_INITDIALOG:
1110  {
1112  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
1113 
1114  pGlobalData->NumWavOut = waveOutGetNumDevs();
1115 
1119 
1120  pGlobalData->hSoundsImageList = InitImageList(IDI_SOUND_SECTION,
1124  IMAGE_ICON);
1125 
1126  LoadEventLabels(pGlobalData);
1127  LoadSoundProfiles(pGlobalData, hwndDlg);
1128  LoadSoundFiles(hwndDlg);
1129  ShowSoundScheme(pGlobalData, hwndDlg);
1130 
1131  if (wParam == (WPARAM)GetDlgItem(hwndDlg, IDC_SOUND_SCHEME))
1132  return TRUE;
1134  return FALSE;
1135  }
1136  case WM_COMMAND:
1137  {
1138  switch (LOWORD(wParam))
1139  {
1140  case IDC_BROWSE_SOUND:
1141  {
1142  ZeroMemory(&ofn, sizeof(ofn));
1143  ofn.lStructSize = sizeof(ofn);
1144  ofn.hwndOwner = hwndDlg;
1146  ofn.lpstrFile[0] = L'\0';
1150  ofn.nFilterIndex = 0;
1153  ofn.lpstrInitialDir = L"%SystemRoot%\\Media";
1155 
1156  if (GetOpenFileNameW(&ofn) != FALSE)
1157  {
1158  // FIXME search if list already contains that sound
1159 
1160  // extract file name
1161  pFileName = wcsrchr(filename, L'\\');
1162  ASSERT(pFileName != NULL);
1163  pFileName++;
1164 
1165  // add to list
1166  lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0, (LPARAM)pFileName);
1167  if (lResult != CB_ERR)
1168  {
1169  // add path and select item
1171  SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0);
1172  }
1173  }
1174  break;
1175  }
1176  case IDC_PLAY_SOUND:
1177  {
1178  LRESULT lIndex;
1179  lIndex = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1180  if (lIndex == CB_ERR)
1181  {
1182  break;
1183  }
1184 
1185  lIndex = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1186  if (lIndex != CB_ERR)
1187  {
1188  PlaySound((TCHAR*)lIndex, NULL, SND_FILENAME);
1189  }
1190  break;
1191  }
1192  case IDC_SOUND_SCHEME:
1193  {
1194  if (HIWORD(wParam) == CBN_SELENDOK)
1195  {
1197  ShowSoundScheme(pGlobalData, hwndDlg);
1202  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1203  }
1204  break;
1205  }
1206  case IDC_SOUND_LIST:
1207  {
1208  if (HIWORD(wParam) == CBN_SELENDOK)
1209  {
1210  PLABEL_CONTEXT pLabelContext;
1211  HTREEITEM hItem;
1212  TVITEM item;
1213  LRESULT lIndex;
1214 
1216  if (hItem == NULL)
1217  {
1218  break;
1219  }
1220 
1221  lIndex = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1222  if (lIndex == CB_ERR)
1223  {
1224  break;
1225  }
1226 
1227  ZeroMemory(&item, sizeof(item));
1228  item.mask = TVIF_PARAM;
1229  item.hItem = hItem;
1231  {
1232  LRESULT lResult;
1233  pLabelContext = (PLABEL_CONTEXT)item.lParam;
1234 
1235  lResult = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1236  if (lResult == CB_ERR || lResult == 0)
1237  {
1238  if (lIndex != pLabelContext->szValue[0])
1239  {
1240  /* Update the tree view item image */
1242  item.iImage = IMAGE_SOUND_NONE;
1243  item.iSelectedImage = IMAGE_SOUND_NONE;
1245 
1246  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1247 
1249  }
1250 
1251  pLabelContext->szValue[0] = L'\0';
1252 
1253  break;
1254  }
1255 
1256  if (_tcsicmp(pLabelContext->szValue, (TCHAR*)lResult) || (lIndex != pLabelContext->szValue[0]))
1257  {
1258  /* Update the tree view item image */
1260  item.iImage = IMAGE_SOUND_ASSIGNED;
1261  item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
1263 
1264  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1265 
1269  _tcscpy(pLabelContext->szValue, (TCHAR*)lResult);
1270  }
1271 
1272  if (_tcslen((TCHAR*)lResult) && lIndex != 0 && pGlobalData->NumWavOut != 0)
1273  {
1275  }
1276  else
1277  {
1279  }
1280  }
1281  }
1282  break;
1283  }
1284  }
1285  break;
1286  }
1287  case WM_DESTROY:
1288  {
1289  FreeSoundProfiles(hwndDlg);
1290  FreeAppMap(pGlobalData);
1291  FreeLabelMap(pGlobalData);
1292  if (pGlobalData->hSoundsImageList)
1293  ImageList_Destroy(pGlobalData->hSoundsImageList);
1294  HeapFree(GetProcessHeap(), 0, pGlobalData);
1295  break;
1296  }
1297  case WM_NOTIFY:
1298  {
1299  PLABEL_CONTEXT pLabelContext;
1300  TCHAR * ptr;
1301 
1302  LPNMHDR lpnm = (LPNMHDR)lParam;
1303 
1304  switch(lpnm->code)
1305  {
1306  case PSN_APPLY:
1307  {
1308  ApplyChanges(hwndDlg);
1309  break;
1310  }
1311  case TVN_SELCHANGED:
1312  {
1314  LRESULT lCount, lIndex, lResult;
1315 
1316  pLabelContext = (PLABEL_CONTEXT)nm->itemNew.lParam;
1317  if (pLabelContext == NULL)
1318  {
1323  return FALSE;
1324  }
1325 
1329 
1330  if (_tcslen(pLabelContext->szValue) == 0)
1331  {
1332  lIndex = ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), 0);
1334  break;
1335  }
1336 
1337  if (pGlobalData->NumWavOut != 0)
1339 
1340  lCount = ComboBox_GetCount(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1341  for (lIndex = 0; lIndex < lCount; lIndex++)
1342  {
1343  lResult = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1344  if (lResult == CB_ERR || lResult == 0)
1345  continue;
1346 
1347  if (!_tcscmp((TCHAR*)lResult, pLabelContext->szValue))
1348  {
1349  ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1350  return FALSE;
1351  }
1352  }
1353 
1354  ptr = _tcsrchr(pLabelContext->szValue, _T('\\'));
1355  if (ptr)
1356  {
1357  ptr++;
1358  }
1359  else
1360  {
1361  ptr = pLabelContext->szValue;
1362  }
1363 
1364  lIndex = ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST), ptr);
1365  if (lIndex != CB_ERR)
1366  {
1367  ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex, _tcsdup(pLabelContext->szValue));
1368  ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1369  }
1370  break;
1371  }
1372  }
1373  }
1374  break;
1375  }
1376 
1377  return FALSE;
1378 }
#define RegQueryValueEx
Definition: winreg.h:524
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
TCHAR * szIcon
Definition: sounds.c:24
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define CB_SETITEMDATA
Definition: winuser.h:1927
#define MAKEINTRESOURCE
Definition: winuser.h:591
static FILEDATA FileData[MAX_FDS]
Definition: fs.c:52
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
Definition: sounds.c:1028
#define IDC_PLAY_SOUND
Definition: resource.h:48
#define TRUE
Definition: types.h:120
BOOL LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
Definition: sounds.c:780
#define IMAGE_ICON
Definition: winuser.h:212
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:16
PLABEL_MAP LabelMap
Definition: sounds.c:36
#define IDI_SOUND_ASSIGNED
Definition: resource.h:11
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID RemoveLabel(PGLOBAL_DATA pGlobalData, PLABEL_MAP pMap)
Definition: sounds.c:127
#define _tcsicmp
Definition: xmlstorage.h:205
HWND hwndOwner
Definition: commdlg.h:330
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3389
PAPP_MAP pAppMap
Definition: sounds.c:59
#define KEY_READ
Definition: nt_native.h:1023
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define IDS_BROWSE_FOR_SOUND
Definition: resource.h:84
BOOL ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
Definition: sounds.c:874
BOOL ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR *szProfile, TCHAR *szLabelName, TCHAR *szAppName, PAPP_MAP AppMap, PLABEL_MAP LabelMap)
Definition: sounds.c:523
#define ComboBox_DeleteString(hwndCtl, index)
Definition: windowsx.h:17
BOOL ApplyChanges(HWND hwndDlg)
Definition: sounds.c:961
TCHAR szValue[MAX_PATH]
Definition: sounds.c:43
#define _countof(array)
Definition: fontsub.cpp:30
#define CB_GETITEMDATA
Definition: winuser.h:1911
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, TCHAR *szSubKey)
Definition: sounds.c:226
#define ExpandEnvironmentStrings
Definition: winbase.h:3588
static const WCHAR szData[]
Definition: msipriv.h:1195
PLABEL_CONTEXT LabelContext
Definition: sounds.c:51
struct _LABEL_CONTEXT * Next
Definition: sounds.c:44
HIMAGELIST hSoundsImageList
Definition: sounds.c:57
#define CALLBACK
Definition: compat.h:27
struct _LABEL_MAP * Next
Definition: sounds.c:26
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define TVI_SORT
Definition: commctrl.h:3343
OPENFILENAME ofn
Definition: main.cpp:37
BOOL LoadSoundFiles(HWND hwndDlg)
Definition: sounds.c:809
#define LPNMTREEVIEW
Definition: commctrl.h:3615
#define IDC_SOUND_LIST
Definition: resource.h:40
BOOL ImportSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
Definition: sounds.c:737
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
struct _SOUND_SCHEME_CONTEXT SOUND_SCHEME_CONTEXT
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:24
HWND WINAPI SetFocus(_In_opt_ HWND)
#define _tcsdup
Definition: tchar.h:625
HINSTANCE hApplet
Definition: access.c:17
#define IMAGE_SOUND_SECTION
Definition: resource.h:94
UINT_PTR WPARAM
Definition: windef.h:207
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3243
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:62
const char * filename
Definition: ioapi.h:135
HIMAGELIST himl
#define BM_SETIMAGE
Definition: winuser.h:1883
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1904
WPARAM wParam
Definition: combotst.c:138
#define pch(ap)
Definition: match.c:418
#define IDS_NO_SOUND
Definition: resource.h:90
#define DWLP_MSGRESULT
Definition: winuser.h:864
struct tagNMHDR * LPNMHDR
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
DWORD nMaxFile
Definition: commdlg.h:337
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:893
#define ILC_COLOR32
Definition: commctrl.h:343
UINT code
Definition: winuser.h:3112
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3384
struct _LABEL_CONTEXT * PLABEL_CONTEXT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PLABEL_MAP LabelMap
Definition: sounds.c:41
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:769
unsigned char * LPBYTE
Definition: typedefs.h:52
#define UNICODE_NULL
LPWSTR MakeFilter(LPWSTR psz)
Definition: sounds.c:65
static VOID FreeLabelMap(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:150
PAPP_MAP AppMap
Definition: sounds.c:42
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CBN_SELENDOK
Definition: winuser.h:1942
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4564
static PVOID ptr
Definition: dispmode.c:27
#define TVI_FIRST
Definition: commctrl.h:3341
#define CB_ADDSTRING
Definition: winuser.h:1897
HTREEITEM hItem
Definition: treelist.h:37
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
struct _APP_MAP * AppMap
Definition: sounds.c:25
static const WCHAR szIcon[]
Definition: dialog.c:152
struct _APP_MAP APP_MAP
TCHAR szDefault[MAX_PATH]
Definition: sounds.c:56
LONG_PTR LPARAM
Definition: windef.h:208
LPTSTR szFilter
Definition: mplay32.c:30
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
Definition: bufpool.h:45
DWORD ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR *szLabelName, TCHAR *szAppName, PAPP_MAP pAppMap)
Definition: sounds.c:587
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
struct _SOUND_SCHEME_CONTEXT * PSOUND_SCHEME_CONTEXT
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3419
#define CB_ERR
Definition: winuser.h:2389
#define WM_DESTROY
Definition: winuser.h:1591
struct _LABEL_MAP * PLABEL_MAP
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define KEY_WRITE
Definition: nt_native.h:1031
char TCHAR
Definition: xmlstorage.h:189
#define IDC_SCHEME_LIST
Definition: resource.h:39
#define IDI_SOUND_SECTION
Definition: resource.h:10
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:23
#define _T(x)
Definition: vfdio.h:22
#define RegEnumKey
Definition: winreg.h:509
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3445
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PLABEL_MAP pLabelMap
Definition: sounds.c:58
if(!(yy_init))
Definition: macro.lex.yy.c:714
TCHAR szName[MAX_PATH]
Definition: sounds.c:49
DWORD EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
Definition: sounds.c:400
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:29
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define TVN_SELCHANGED
Definition: commctrl.h:3707
struct _LABEL_MAP LABEL_MAP
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define MAX_PATH
Definition: compat.h:26
#define IMAGE_SOUND_NONE
Definition: resource.h:96
PSOUND_SCHEME_CONTEXT FindSoundProfile(HWND hwndDlg, TCHAR *szName)
Definition: sounds.c:457
DWORD lStructSize
Definition: commdlg.h:329
TCHAR szIcon[MAX_PATH]
Definition: sounds.c:33
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
struct _GLOBAL_DATA * PGLOBAL_DATA
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:505
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:37
#define IMAGE_SOUND_ASSIGNED
Definition: resource.h:95
#define TVI_ROOT
Definition: commctrl.h:3340
TCHAR szName[MAX_PATH]
Definition: sounds.c:31
INT_PTR CALLBACK SoundsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: sounds.c:1092
#define SM_CXSMICON
Definition: winuser.h:1002
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PSNRET_NOERROR
Definition: prsht.h:129
int ret
UINT NumWavOut
Definition: sounds.c:60
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define StringCchCopy
Definition: strsafe.h:139
#define IDS_WAVE_FILES_FILTER
Definition: resource.h:85
#define DWLP_USER
Definition: winuser.h:866
#define LR_LOADTRANSPARENT
Definition: winuser.h:1083
TCHAR szDesc[MAX_PATH]
Definition: sounds.c:32
#define ILC_MASK
Definition: commctrl.h:336
#define IDC_SOUND_SCHEME
Definition: resource.h:38
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define CB_SETCURSEL
Definition: winuser.h:1922
#define WM_COMMAND
Definition: winuser.h:1716
_In_ HANDLE hFile
Definition: mswsock.h:90
#define RegEnumKeyEx
Definition: winreg.h:510
static VOID FreeSoundProfiles(HWND hwndDlg)
Definition: sounds.c:489
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:41
#define TVIS_EXPANDED
Definition: commctrl.h:3256
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
TCHAR szAppName[128]
Definition: solitaire.cpp:16
#define IDI_PLAY_ICON
Definition: resource.h:5
#define TVITEM
Definition: commctrl.h:3337
#define _stprintf
Definition: utility.h:124
#define SND_FILENAME
Definition: mmsystem.h:162
HWND hList
Definition: livecd.c:10
HWND WINAPI GetParent(_In_ HWND)
TCHAR * szDesc
Definition: sounds.c:23
#define RegOpenKeyEx
Definition: winreg.h:520
PAPP_MAP FindApp(PGLOBAL_DATA pGlobalData, TCHAR *szName)
Definition: sounds.c:162
#define PlaySound
Definition: mmsystem.h:2832
#define TEXT(s)
Definition: k32.h:26
static ATOM item
Definition: dde.c:856
LPSTR lpstrFile
Definition: commdlg.h:336
#define ComboBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:44
#define TVIF_TEXT
Definition: commctrl.h:3238
struct _GLOBAL_DATA GLOBAL_DATA
LPCWSTR szPath
Definition: env.c:35
PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, TCHAR *szName)
Definition: sounds.c:82
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
struct _APP_MAP * Next
Definition: sounds.c:35
#define TVINSERTSTRUCT
Definition: commctrl.h:3374
#define TVIF_IMAGE
Definition: commctrl.h:3239
BOOL LoadEventLabels(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:292
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDC_BROWSE_SOUND
Definition: resource.h:49
PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT pSoundScheme, TCHAR *AppName, TCHAR *LabelName)
Definition: sounds.c:191
LPCSTR lpstrFilter
Definition: commdlg.h:332
unsigned int UINT
Definition: ndis.h:50
BOOL AddSoundProfile(HWND hwndDlg, HKEY hKey, TCHAR *szSubKey, BOOL SetDefault)
Definition: sounds.c:340
#define IMAGE_BITMAP
Definition: winuser.h:211
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3469
#define IDC_TEXT_SOUND
Definition: resource.h:47
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define TVSIL_NORMAL
Definition: commctrl.h:3415
static const WCHAR szName[]
Definition: msipriv.h:1194
struct _APP_MAP * PAPP_MAP
#define SendMessage
Definition: winuser.h:5709
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define TVIF_STATE
Definition: commctrl.h:3241
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:528
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define TVIF_PARAM
Definition: commctrl.h:3240
#define LoadIcon
Definition: winuser.h:5679
#define GetWindowLongPtr
Definition: treelist.c:73
DWORD nFilterIndex
Definition: commdlg.h:335
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
DWORD ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR *szAppName)
Definition: sounds.c:646
struct _LABEL_CONTEXT LABEL_CONTEXT
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
TCHAR * szName
Definition: sounds.c:22
static VOID FreeAppMap(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:179
#define RegSetValueEx
Definition: winreg.h:533
#define LoadString
Definition: winuser.h:5685
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3462
#define WM_NOTIFY
Definition: richedit.h:61
TCHAR szDesc[MAX_PATH]
Definition: sounds.c:50
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
DWORD Flags
Definition: commdlg.h:342
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502