ReactOS 0.4.15-dev-5875-g7c755d9
sounds.c File Reference
#include "mmsys.h"
#include <commdlg.h>
#include <windowsx.h>
#include <debug.h>
Include dependency graph for sounds.c:

Go to the source code of this file.

Classes

struct  _LABEL_MAP
 
struct  _APP_MAP
 
struct  _LABEL_CONTEXT
 
struct  _SOUND_SCHEME_CONTEXT
 
struct  _GLOBAL_DATA
 

Typedefs

typedef struct _LABEL_MAP LABEL_MAP
 
typedef struct _LABEL_MAPPLABEL_MAP
 
typedef struct _APP_MAP APP_MAP
 
typedef struct _APP_MAPPAPP_MAP
 
typedef struct _LABEL_CONTEXT LABEL_CONTEXT
 
typedef struct _LABEL_CONTEXTPLABEL_CONTEXT
 
typedef struct _SOUND_SCHEME_CONTEXT SOUND_SCHEME_CONTEXT
 
typedef struct _SOUND_SCHEME_CONTEXTPSOUND_SCHEME_CONTEXT
 
typedef struct _GLOBAL_DATA GLOBAL_DATA
 
typedef struct _GLOBAL_DATAPGLOBAL_DATA
 

Functions

LPWSTR MakeFilter (LPWSTR psz)
 
PLABEL_MAP FindLabel (PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, PWCHAR szName)
 
VOID RemoveLabel (PGLOBAL_DATA pGlobalData, PLABEL_MAP pMap)
 
static VOID FreeLabelMap (PGLOBAL_DATA pGlobalData)
 
PAPP_MAP FindApp (PGLOBAL_DATA pGlobalData, PWCHAR szName)
 
static VOID FreeAppMap (PGLOBAL_DATA pGlobalData)
 
PLABEL_CONTEXT FindLabelContext (PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT pSoundScheme, PWCHAR AppName, PWCHAR LabelName)
 
BOOL LoadEventLabel (PGLOBAL_DATA pGlobalData, HKEY hKey, PWCHAR szSubKey)
 
BOOL LoadEventLabels (PGLOBAL_DATA pGlobalData)
 
BOOL AddSoundProfile (HWND hwndDlg, HKEY hKey, PWCHAR szSubKey, BOOL SetDefault)
 
DWORD EnumerateSoundProfiles (PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
 
PSOUND_SCHEME_CONTEXT FindSoundProfile (HWND hwndDlg, PWCHAR szName)
 
static VOID FreeSoundProfiles (HWND hwndDlg)
 
BOOL ImportSoundLabel (PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szProfile, PWCHAR szLabelName, PWCHAR szAppName, PAPP_MAP AppMap, PLABEL_MAP LabelMap)
 
DWORD ImportSoundEntry (PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szLabelName, PWCHAR szAppName, PAPP_MAP pAppMap)
 
DWORD ImportAppProfile (PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szAppName)
 
BOOL ImportSoundProfiles (PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
 
BOOL LoadSoundProfiles (PGLOBAL_DATA pGlobalData, HWND hwndDlg)
 
BOOL LoadSoundFiles (HWND hwndDlg)
 
static VOID FreeSoundFiles (HWND hwndDlg)
 
static LRESULT FindSoundFileInList (HWND hwndDlg, LPCWSTR pSoundPath)
 
BOOL ShowSoundScheme (PGLOBAL_DATA pGlobalData, HWND hwndDlg)
 
BOOL ApplyChanges (HWND hwndDlg)
 
HIMAGELIST InitImageList (UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
 
INT_PTR CALLBACK SoundsDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ APP_MAP

◆ GLOBAL_DATA

◆ LABEL_CONTEXT

◆ LABEL_MAP

◆ PAPP_MAP

◆ PGLOBAL_DATA

◆ PLABEL_CONTEXT

◆ PLABEL_MAP

◆ PSOUND_SCHEME_CONTEXT

◆ SOUND_SCHEME_CONTEXT

Function Documentation

◆ AddSoundProfile()

BOOL AddSoundProfile ( HWND  hwndDlg,
HKEY  hKey,
PWCHAR  szSubKey,
BOOL  SetDefault 
)

Definition at line 349 of file sounds.c.

350{
351 HKEY hSubKey;
352 WCHAR szValue[MAX_PATH];
353 DWORD cbValue, dwResult;
354 LRESULT lResult;
355 PSOUND_SCHEME_CONTEXT pScheme;
356
358 szSubKey,
359 0,
360 KEY_READ,
361 &hSubKey) != ERROR_SUCCESS)
362 {
363 return FALSE;
364 }
365
366 cbValue = sizeof(szValue);
367 dwResult = RegQueryValueExW(hSubKey,
368 NULL,
369 NULL,
370 NULL,
371 (LPBYTE)szValue,
372 &cbValue);
373 RegCloseKey(hSubKey);
374
375 if (dwResult != ERROR_SUCCESS)
376 return FALSE;
377
378 /* Try to add the new profile */
379 lResult = ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), szValue);
380 if (lResult == CB_ERR)
381 return FALSE;
382
383 /* Allocate the profile scheme buffer */
385 if (pScheme == NULL)
386 {
387 /* We failed to allocate the buffer, no need to keep a dangling string in the combobox */
389 return FALSE;
390 }
391
392 StringCchCopyW(pScheme->szDesc, _countof(pScheme->szDesc), szValue);
393 StringCchCopyW(pScheme->szName, _countof(pScheme->szName), szSubKey);
394
395 /* Associate the value with the item in the combobox */
396 ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), lResult, pScheme);
397
398 /* Optionally, select the profile */
399 if (SetDefault)
400 {
402 }
403
404 return TRUE;
405}
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_SOUND_SCHEME
Definition: resource.h:38
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define KEY_READ
Definition: nt_native.h:1023
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
WCHAR szDesc[MAX_PATH]
Definition: sounds.c:49
WCHAR szName[MAX_PATH]
Definition: sounds.c:48
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG_PTR LRESULT
Definition: windef.h:209
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:66
#define ComboBox_DeleteString(hwndCtl, index)
Definition: windowsx.h:42
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:41
#define ComboBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:69
#define CB_ERR
Definition: winuser.h:2425
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by EnumerateSoundProfiles().

◆ ApplyChanges()

BOOL ApplyChanges ( HWND  hwndDlg)

Definition at line 1014 of file sounds.c.

1015{
1016 HKEY hKey, hSubKey;
1017 DWORD dwType;
1018 LRESULT lIndex;
1019 PSOUND_SCHEME_CONTEXT pScheme;
1020 HWND hDlgCtrl;
1021 PLABEL_CONTEXT pLabelContext;
1022 WCHAR Buffer[100];
1023
1024 hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
1025
1026 lIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
1027 if (lIndex == CB_ERR)
1028 {
1029 return FALSE;
1030 }
1031
1032 lIndex = SendMessageW(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, 0);
1033 if (lIndex == CB_ERR)
1034 {
1035 return FALSE;
1036 }
1037 pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
1038
1040 L"AppEvents\\Schemes",
1041 0,
1042 KEY_WRITE,
1043 &hKey) != ERROR_SUCCESS)
1044 {
1045 return FALSE;
1046 }
1047
1048 RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pScheme->szName, (wcslen(pScheme->szName) + 1) * sizeof(WCHAR));
1050
1052 L"AppEvents\\Schemes\\Apps",
1053 0,
1054 KEY_WRITE,
1055 &hKey) != ERROR_SUCCESS)
1056 {
1057 return FALSE;
1058 }
1059
1060 pLabelContext = pScheme->LabelContext;
1061
1062 while (pLabelContext)
1063 {
1064 StringCchPrintfW(Buffer, _countof(Buffer), L"%s\\%s\\.Current", pLabelContext->AppMap->szName, pLabelContext->LabelMap->szName);
1065
1066 if (RegOpenKeyExW(hKey, Buffer, 0, KEY_WRITE, &hSubKey) == ERROR_SUCCESS)
1067 {
1068 dwType = (wcschr(pLabelContext->szValue, L'%') ? REG_EXPAND_SZ : REG_SZ);
1069 RegSetValueExW(hSubKey, NULL, 0, dwType, (LPBYTE)pLabelContext->szValue, (wcslen(pLabelContext->szValue) + 1) * sizeof(WCHAR));
1070 RegCloseKey(hSubKey);
1071 }
1072
1073 pLabelContext = pLabelContext->Next;
1074 }
1076
1078 return TRUE;
1079}
Definition: bufpool.h:45
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4900
#define wcschr
Definition: compat.h:17
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
#define PSNRET_NOERROR
Definition: prsht.h:129
struct _SOUND_SCHEME_CONTEXT * PSOUND_SCHEME_CONTEXT
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
PAPP_MAP AppMap
Definition: sounds.c:41
PLABEL_MAP LabelMap
Definition: sounds.c:40
struct _LABEL_CONTEXT * Next
Definition: sounds.c:43
WCHAR szValue[MAX_PATH]
Definition: sounds.c:42
PWCHAR szName
Definition: sounds.c:21
PLABEL_CONTEXT LabelContext
Definition: sounds.c:50
UINT_PTR WPARAM
Definition: windef.h:207
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define CB_GETITEMDATA
Definition: winuser.h:1940
#define DWLP_MSGRESULT
Definition: winuser.h:864
#define CB_GETCURSEL
Definition: winuser.h:1933
#define SetWindowLongPtrW
Definition: winuser.h:5336
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by SepAdjustGroups(), SepAdjustPrivileges(), and SoundsDlgProc().

◆ EnumerateSoundProfiles()

DWORD EnumerateSoundProfiles ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg,
HKEY  hKey 
)

Definition at line 409 of file sounds.c.

410{
411 HKEY hSubKey;
412 DWORD dwName, dwCurKey, dwResult, dwNumSchemes;
413 DWORD cbDefault;
415
416 cbDefault = sizeof(pGlobalData->szDefault);
418 NULL,
419 NULL,
420 NULL,
421 (LPBYTE)pGlobalData->szDefault,
422 &cbDefault) != ERROR_SUCCESS)
423 {
424 return FALSE;
425 }
426
428 L"Names",
429 0,
430 KEY_READ,
431 &hSubKey) != ERROR_SUCCESS)
432 {
433 return FALSE;
434 }
435
436 dwNumSchemes = 0;
437 dwCurKey = 0;
438 do
439 {
440 dwName = _countof(szName);
441 dwResult = RegEnumKeyExW(hSubKey,
442 dwCurKey,
443 szName,
444 &dwName,
445 NULL,
446 NULL,
447 NULL,
448 NULL);
449
450 if (dwResult == ERROR_SUCCESS)
451 {
452 if (AddSoundProfile(hwndDlg, hSubKey, szName, (!_wcsicmp(szName, pGlobalData->szDefault))))
453 {
454 dwNumSchemes++;
455 }
456 }
457
458 dwCurKey++;
459 } while (dwResult == ERROR_SUCCESS);
460
461 RegCloseKey(hSubKey);
462 return dwNumSchemes;
463}
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
static const WCHAR szName[]
Definition: powrprof.c:45
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL AddSoundProfile(HWND hwndDlg, HKEY hKey, PWCHAR szSubKey, BOOL SetDefault)
Definition: sounds.c:349
WCHAR szDefault[MAX_PATH]
Definition: sounds.c:55

Referenced by LoadSoundProfiles().

◆ FindApp()

PAPP_MAP FindApp ( PGLOBAL_DATA  pGlobalData,
PWCHAR  szName 
)

Definition at line 171 of file sounds.c.

172{
173 PAPP_MAP pMap = pGlobalData->pAppMap;
174
175 while (pMap)
176 {
177 if (!wcscmp(pMap->szName, szName))
178 return pMap;
179
180 pMap = pMap->Next;
181
182 }
183 return NULL;
184}
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct _APP_MAP * Next
Definition: sounds.c:34
PAPP_MAP pAppMap
Definition: sounds.c:58

Referenced by FindLabelContext().

◆ FindLabel()

PLABEL_MAP FindLabel ( PGLOBAL_DATA  pGlobalData,
PAPP_MAP  pAppMap,
PWCHAR  szName 
)

Definition at line 81 of file sounds.c.

82{
83 PLABEL_MAP pMap = pGlobalData->pLabelMap;
84
85 while (pMap)
86 {
87 ASSERT(pMap);
88 ASSERT(pMap->szName);
89 if (!wcscmp(pMap->szName, szName))
90 return pMap;
91
92 pMap = pMap->Next;
93 }
94
95 pMap = pAppMap->LabelMap;
96
97 while (pMap)
98 {
99 ASSERT(pMap);
100 ASSERT(pMap->szName);
101 if (!wcscmp(pMap->szName, szName))
102 return pMap;
103
104 pMap = pMap->Next;
105 }
106
108 if (!pMap)
109 return NULL;
110
111 pMap->szName = pMap->szDesc = _wcsdup(szName);
112 if (!pMap->szName)
113 {
114 HeapFree(GetProcessHeap(), 0, pMap);
115 return NULL;
116 }
117
118 pMap->AppMap = pAppMap;
119 pMap->Next = pGlobalData->pLabelMap;
120 pGlobalData->pLabelMap = pMap;
121
122 return pMap;
123}
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ASSERT(a)
Definition: mode.c:44
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
PLABEL_MAP LabelMap
Definition: sounds.c:35
PLABEL_MAP pLabelMap
Definition: sounds.c:57
PWCHAR szDesc
Definition: sounds.c:22
struct _APP_MAP * AppMap
Definition: sounds.c:24
struct _LABEL_MAP * Next
Definition: sounds.c:25

Referenced by FindLabelContext(), and ImportSoundEntry().

◆ FindLabelContext()

PLABEL_CONTEXT FindLabelContext ( PGLOBAL_DATA  pGlobalData,
PSOUND_SCHEME_CONTEXT  pSoundScheme,
PWCHAR  AppName,
PWCHAR  LabelName 
)

Definition at line 200 of file sounds.c.

201{
202 PLABEL_CONTEXT pLabelContext;
203
204 pLabelContext = pSoundScheme->LabelContext;
205
206 while (pLabelContext)
207 {
208 ASSERT(pLabelContext->AppMap);
209 ASSERT(pLabelContext->LabelMap);
210
211 if (!_wcsicmp(pLabelContext->AppMap->szName, AppName) && !_wcsicmp(pLabelContext->LabelMap->szName, LabelName))
212 {
213 return pLabelContext;
214 }
215 pLabelContext = pLabelContext->Next;
216 }
217
218 pLabelContext = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LABEL_CONTEXT));
219 if (!pLabelContext)
220 return NULL;
221
222 pLabelContext->AppMap = FindApp(pGlobalData, AppName);
223 pLabelContext->LabelMap = FindLabel(pGlobalData, pLabelContext->AppMap, LabelName);
224 ASSERT(pLabelContext->AppMap);
225 ASSERT(pLabelContext->LabelMap);
226 pLabelContext->szValue[0] = UNICODE_NULL;
227 pLabelContext->Next = pSoundScheme->LabelContext;
228 pSoundScheme->LabelContext = pLabelContext;
229
230 return pLabelContext;
231}
@ LabelName
Definition: asmpp.cpp:94
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define UNICODE_NULL
PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, PWCHAR szName)
Definition: sounds.c:81
PAPP_MAP FindApp(PGLOBAL_DATA pGlobalData, PWCHAR szName)
Definition: sounds.c:171

Referenced by ImportSoundLabel(), and ShowSoundScheme().

◆ FindSoundFileInList()

static LRESULT FindSoundFileInList ( HWND  hwndDlg,
LPCWSTR  pSoundPath 
)
static

Definition at line 901 of file sounds.c.

902{
903 LRESULT lCount, lIndex, lResult;
904 LPWSTR pszPath;
905 HWND hwndComboBox;
906
907 hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_LIST);
908 lCount = ComboBox_GetCount(hwndComboBox);
909 if (lCount == CB_ERR)
910 return CB_ERR;
911
912 for (lIndex = 0; lIndex < lCount; lIndex++)
913 {
914 lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
915 if (lResult == CB_ERR || lResult == 0)
916 continue;
917
918 pszPath = (LPWSTR)lResult;
919 if (_wcsicmp(pszPath, pSoundPath) == 0)
920 return lIndex;
921 }
922
923 return CB_ERR;
924}
#define IDC_SOUND_LIST
Definition: resource.h:40
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:54
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:48
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by SoundsDlgProc().

◆ FindSoundProfile()

PSOUND_SCHEME_CONTEXT FindSoundProfile ( HWND  hwndDlg,
PWCHAR  szName 
)

Definition at line 466 of file sounds.c.

467{
468 LRESULT lCount, lIndex, lResult;
469 PSOUND_SCHEME_CONTEXT pScheme;
470 HWND hwndComboBox;
471
472 hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
473 lCount = ComboBox_GetCount(hwndComboBox);
474 if (lCount == CB_ERR)
475 {
476 return NULL;
477 }
478
479 for (lIndex = 0; lIndex < lCount; lIndex++)
480 {
481 lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
482 if (lResult == CB_ERR)
483 {
484 continue;
485 }
486
487 pScheme = (PSOUND_SCHEME_CONTEXT)lResult;
488 if (!_wcsicmp(pScheme->szName, szName))
489 {
490 return pScheme;
491 }
492 }
493 return NULL;
494}

Referenced by ImportSoundLabel().

◆ FreeAppMap()

static VOID FreeAppMap ( PGLOBAL_DATA  pGlobalData)
static

Definition at line 188 of file sounds.c.

189{
190 PAPP_MAP pCurMap;
191
192 while (pGlobalData->pAppMap)
193 {
194 pCurMap = pGlobalData->pAppMap->Next;
195 HeapFree(GetProcessHeap(), 0, pGlobalData->pAppMap);
196 pGlobalData->pAppMap = pCurMap;
197 }
198}

Referenced by SoundsDlgProc().

◆ FreeLabelMap()

static VOID FreeLabelMap ( PGLOBAL_DATA  pGlobalData)
static

Definition at line 149 of file sounds.c.

150{
151 PLABEL_MAP pCurMap;
152
153 while (pGlobalData->pLabelMap)
154 {
155 pCurMap = pGlobalData->pLabelMap->Next;
156
157 /* Prevent double freeing (for "FindLabel") */
158 if (pGlobalData->pLabelMap->szName != pGlobalData->pLabelMap->szDesc)
159 {
160 free(pGlobalData->pLabelMap->szName);
161 }
162
163 free(pGlobalData->pLabelMap->szDesc);
164 free(pGlobalData->pLabelMap->szIcon);
165
166 HeapFree(GetProcessHeap(), 0, pGlobalData->pLabelMap);
167 pGlobalData->pLabelMap = pCurMap;
168 }
169}
#define free
Definition: debug_ros.c:5
PWCHAR szIcon
Definition: sounds.c:23

Referenced by SoundsDlgProc().

◆ FreeSoundFiles()

static VOID FreeSoundFiles ( HWND  hwndDlg)
static

Definition at line 875 of file sounds.c.

876{
877 LRESULT lCount, lIndex, lResult;
878 PWCHAR pSoundPath;
879 HWND hwndComboBox;
880
881 hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_LIST);
882 lCount = ComboBox_GetCount(hwndComboBox);
883 if (lCount == CB_ERR)
884 return;
885
886 for (lIndex = 0; lIndex < lCount; lIndex++)
887 {
888 lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
889 if (lResult == CB_ERR)
890 {
891 continue;
892 }
893
894 pSoundPath = (PWCHAR)lResult;
895 free(pSoundPath);
896 }
897}
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by SoundsDlgProc().

◆ FreeSoundProfiles()

static VOID FreeSoundProfiles ( HWND  hwndDlg)
static

Definition at line 498 of file sounds.c.

499{
500 LRESULT lCount, lIndex, lResult;
501 PSOUND_SCHEME_CONTEXT pScheme;
502 PLABEL_CONTEXT pLabelContext;
503 HWND hwndComboBox;
504
505 hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
506 lCount = ComboBox_GetCount(hwndComboBox);
507 if (lCount == CB_ERR)
508 return;
509
510 for (lIndex = 0; lIndex < lCount; lIndex++)
511 {
512 lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
513 if (lResult == CB_ERR)
514 {
515 continue;
516 }
517
518 pScheme = (PSOUND_SCHEME_CONTEXT)lResult;
519
520 while (pScheme->LabelContext)
521 {
522 pLabelContext = pScheme->LabelContext->Next;
523 HeapFree(GetProcessHeap(), 0, pScheme->LabelContext);
524 pScheme->LabelContext = pLabelContext;
525 }
526
527 HeapFree(GetProcessHeap(), 0, pScheme);
528 }
529}

Referenced by SoundsDlgProc().

◆ ImportAppProfile()

DWORD ImportAppProfile ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg,
HKEY  hKey,
PWCHAR  szAppName 
)

Definition at line 652 of file sounds.c.

653{
654 HKEY hSubKey;
655 WCHAR szDefault[MAX_PATH];
656 DWORD cbValue;
657 DWORD dwCurKey;
658 DWORD dwResult;
659 DWORD dwNumEntry;
660 DWORD dwName;
662 WCHAR szIcon[MAX_PATH];
663 PAPP_MAP AppMap;
664
665 AppMap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APP_MAP));
666 if (!AppMap)
667 return 0;
668
670 szAppName,
671 0,
672 KEY_READ,
673 &hSubKey) != ERROR_SUCCESS)
674 {
675 HeapFree(GetProcessHeap(), 0, AppMap);
676 return 0;
677 }
678
679 cbValue = sizeof(szDefault);
680 if (RegQueryValueExW(hSubKey,
681 NULL,
682 NULL,
683 NULL,
684 (LPBYTE)szDefault,
685 &cbValue) != ERROR_SUCCESS)
686 {
687 RegCloseKey(hSubKey);
688 HeapFree(GetProcessHeap(), 0, AppMap);
689 return 0;
690 }
691
692 cbValue = sizeof(szIcon);
693 if (RegQueryValueExW(hSubKey,
694 L"DispFileName",
695 NULL,
696 NULL,
697 (LPBYTE)szIcon,
698 &cbValue) != ERROR_SUCCESS)
699 {
700 szIcon[0] = UNICODE_NULL;
701 }
702
703 /* initialize app map */
704 StringCchCopyW(AppMap->szName, _countof(AppMap->szName), szAppName);
705 StringCchCopyW(AppMap->szDesc, _countof(AppMap->szDesc), szDefault);
706 StringCchCopyW(AppMap->szIcon, _countof(AppMap->szIcon), szIcon);
707
708 AppMap->Next = pGlobalData->pAppMap;
709 pGlobalData->pAppMap = AppMap;
710
711
712 dwCurKey = 0;
713 dwNumEntry = 0;
714 do
715 {
716 dwName = _countof(szName);
717 dwResult = RegEnumKeyExW(hSubKey,
718 dwCurKey,
719 szName,
720 &dwName,
721 NULL,
722 NULL,
723 NULL,
724 NULL);
725 if (dwResult == ERROR_SUCCESS)
726 {
727 if (ImportSoundEntry(pGlobalData, hwndDlg, hSubKey, szName, szAppName, AppMap))
728 {
729 dwNumEntry++;
730 }
731 }
732 dwCurKey++;
733 } while (dwResult == ERROR_SUCCESS);
734
735 RegCloseKey(hSubKey);
736 return dwNumEntry;
737}
TCHAR szAppName[128]
Definition: solitaire.cpp:17
DWORD ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szLabelName, PWCHAR szAppName, PAPP_MAP pAppMap)
Definition: sounds.c:593
WCHAR szDesc[MAX_PATH]
Definition: sounds.c:31
WCHAR szIcon[MAX_PATH]
Definition: sounds.c:32

Referenced by ImportSoundProfiles().

◆ ImportSoundEntry()

DWORD ImportSoundEntry ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg,
HKEY  hKey,
PWCHAR  szLabelName,
PWCHAR  szAppName,
PAPP_MAP  pAppMap 
)

Definition at line 593 of file sounds.c.

594{
595 HKEY hSubKey;
596 DWORD dwNumProfiles;
597 DWORD dwCurKey;
598 DWORD dwResult;
599 DWORD dwProfile;
600 WCHAR szProfile[MAX_PATH];
601 PLABEL_MAP pLabel;
602
604 szLabelName,
605 0,
606 KEY_READ,
607 &hSubKey) != ERROR_SUCCESS)
608 {
609 return FALSE;
610 }
611 pLabel = FindLabel(pGlobalData, pAppMap, szLabelName);
612
613 ASSERT(pLabel);
614 RemoveLabel(pGlobalData, pLabel);
615
616 pLabel->AppMap = pAppMap;
617 pLabel->Next = pAppMap->LabelMap;
618 pAppMap->LabelMap = pLabel;
619
620 dwNumProfiles = 0;
621 dwCurKey = 0;
622 do
623 {
624 dwProfile = _countof(szProfile);
625 dwResult = RegEnumKeyExW(hSubKey,
626 dwCurKey,
627 szProfile,
628 &dwProfile,
629 NULL,
630 NULL,
631 NULL,
632 NULL);
633
634 if (dwResult == ERROR_SUCCESS)
635 {
636 if (ImportSoundLabel(pGlobalData, hwndDlg, hSubKey, szProfile, szLabelName, szAppName, pAppMap, pLabel))
637 {
638 dwNumProfiles++;
639 }
640 }
641
642 dwCurKey++;
643 } while (dwResult == ERROR_SUCCESS);
644
645 RegCloseKey(hSubKey);
646
647 return dwNumProfiles;
648}
VOID RemoveLabel(PGLOBAL_DATA pGlobalData, PLABEL_MAP pMap)
Definition: sounds.c:126
BOOL ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szProfile, PWCHAR szLabelName, PWCHAR szAppName, PAPP_MAP AppMap, PLABEL_MAP LabelMap)
Definition: sounds.c:532

Referenced by ImportAppProfile().

◆ ImportSoundLabel()

BOOL ImportSoundLabel ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg,
HKEY  hKey,
PWCHAR  szProfile,
PWCHAR  szLabelName,
PWCHAR  szAppName,
PAPP_MAP  AppMap,
PLABEL_MAP  LabelMap 
)

Definition at line 532 of file sounds.c.

533{
534 HKEY hSubKey;
535 WCHAR szValue[MAX_PATH];
536 WCHAR szBuffer[MAX_PATH];
537 DWORD cbValue, cchLength;
538 PSOUND_SCHEME_CONTEXT pScheme;
539 PLABEL_CONTEXT pLabelContext;
540 BOOL bCurrentProfile, bActiveProfile;
541
542 bCurrentProfile = !_wcsicmp(szProfile, L".Current");
543 bActiveProfile = !_wcsicmp(szProfile, pGlobalData->szDefault);
544
546 szProfile,
547 0,
548 KEY_READ,
549 &hSubKey) != ERROR_SUCCESS)
550 {
551 return FALSE;
552 }
553
554 cbValue = sizeof(szValue);
555 if (RegQueryValueExW(hSubKey,
556 NULL,
557 NULL,
558 NULL,
559 (LPBYTE)szValue,
560 &cbValue) != ERROR_SUCCESS)
561 {
562 return FALSE;
563 }
564
565 if (bCurrentProfile)
566 pScheme = FindSoundProfile(hwndDlg, pGlobalData->szDefault);
567 else
568 pScheme = FindSoundProfile(hwndDlg, szProfile);
569
570 if (!pScheme)
571 {
572 return FALSE;
573 }
574 pLabelContext = FindLabelContext(pGlobalData, pScheme, AppMap->szName, LabelMap->szName);
575
576 cchLength = ExpandEnvironmentStringsW(szValue, szBuffer, _countof(szBuffer));
577 if (cchLength == 0 || cchLength > _countof(szBuffer))
578 {
579 /* fixme */
580 return FALSE;
581 }
582
583 if (bCurrentProfile)
584 StringCchCopyW(pLabelContext->szValue, _countof(pLabelContext->szValue), szBuffer);
585 else if (!bActiveProfile)
586 StringCchCopyW(pLabelContext->szValue, _countof(pLabelContext->szValue), szBuffer);
587
588 return TRUE;
589}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
unsigned int BOOL
Definition: ntddk_ex.h:94
PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT pSoundScheme, PWCHAR AppName, PWCHAR LabelName)
Definition: sounds.c:200
PSOUND_SCHEME_CONTEXT FindSoundProfile(HWND hwndDlg, PWCHAR szName)
Definition: sounds.c:466

Referenced by ImportSoundEntry().

◆ ImportSoundProfiles()

BOOL ImportSoundProfiles ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg,
HKEY  hKey 
)

Definition at line 741 of file sounds.c.

742{
743 DWORD dwCurKey;
744 DWORD dwResult;
745 DWORD dwNumApps;
747 HKEY hSubKey;
748
750 L"Apps",
751 0,
752 KEY_READ,
753 &hSubKey) != ERROR_SUCCESS)
754 {
755 return FALSE;
756 }
757
758 dwNumApps = 0;
759 dwCurKey = 0;
760 do
761 {
762 dwResult = RegEnumKeyW(hSubKey,
763 dwCurKey,
764 szName,
766
767 if (dwResult == ERROR_SUCCESS)
768 {
769 if (ImportAppProfile(pGlobalData, hwndDlg, hSubKey, szName))
770 {
771 dwNumApps++;
772 }
773 }
774 dwCurKey++;
775 } while (dwResult == ERROR_SUCCESS);
776
777 RegCloseKey(hSubKey);
778
779 return (dwNumApps != 0);
780}
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
DWORD ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szAppName)
Definition: sounds.c:652

Referenced by LoadSoundProfiles().

◆ InitImageList()

HIMAGELIST InitImageList ( UINT  StartResource,
UINT  EndResource,
UINT  Width,
UINT  Height,
ULONG  type 
)

Definition at line 1083 of file sounds.c.

1088{
1089 HANDLE hImage;
1091 UINT i;
1092 INT ret;
1093
1094 /* Create the toolbar icon image list */
1096 Height,
1098 EndResource - StartResource,
1099 0);
1100 if (himl == NULL)
1101 return NULL;
1102
1103 ret = 0;
1104 for (i = StartResource; i <= EndResource && ret != -1; i++)
1105 {
1106 hImage = LoadImageW(hApplet,
1108 type,
1109 Width,
1110 Height,
1112 if (hImage == NULL)
1113 {
1114 ret = -1;
1115 break;
1116 }
1117
1118 if (type == IMAGE_BITMAP)
1119 {
1121 hImage,
1122 RGB(255, 0, 128));
1123 }
1124 else if (type == IMAGE_ICON)
1125 {
1127 hImage);
1128 }
1129
1130 DeleteObject(hImage);
1131 }
1132
1133 if (ret == -1)
1134 {
1136 himl = NULL;
1137 }
1138
1139 return himl;
1140}
HIMAGELIST himl
HINSTANCE hApplet
Definition: access.c:17
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define RGB(r, g, b)
Definition: precomp.h:62
pKey DeleteObject()
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
unsigned int UINT
Definition: ndis.h:50
#define ILC_COLOR32
Definition: commctrl.h:358
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
int32_t INT
Definition: typedefs.h:58
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:126
_In_ HFONT _Out_ PUINT Height
Definition: font.h:125
int ret
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LR_LOADTRANSPARENT
Definition: winuser.h:1087
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define IMAGE_ICON
Definition: winuser.h:212
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by SoundsDlgProc().

◆ LoadEventLabel()

BOOL LoadEventLabel ( PGLOBAL_DATA  pGlobalData,
HKEY  hKey,
PWCHAR  szSubKey 
)

Definition at line 235 of file sounds.c.

236{
237 HKEY hSubKey;
238 DWORD cbValue;
239 WCHAR szDesc[MAX_PATH];
240 WCHAR szData[MAX_PATH];
241 PLABEL_MAP pMap;
242
244 szSubKey,
245 0,
246 KEY_READ,
247 &hSubKey) != ERROR_SUCCESS)
248 {
249 return FALSE;
250 }
251
252 cbValue = sizeof(szDesc);
253 if (RegQueryValueExW(hSubKey,
254 NULL,
255 NULL,
256 NULL,
257 (LPBYTE)szDesc,
258 &cbValue) != ERROR_SUCCESS)
259 {
260 RegCloseKey(hSubKey);
261 return FALSE;
262 }
263
264 cbValue = sizeof(szData);
265 if (RegQueryValueExW(hSubKey,
266 L"DispFileName",
267 NULL,
268 NULL,
269 (LPBYTE)szData,
270 &cbValue) != ERROR_SUCCESS)
271 {
272 RegCloseKey(hSubKey);
273 return FALSE;
274 }
275
277 if (!pMap)
278 {
279 return FALSE;
280 }
281
282 pMap->szName = _wcsdup(szSubKey);
283 pMap->szDesc = _wcsdup(szDesc);
284 pMap->szIcon = _wcsdup(szData);
285
286 if (pGlobalData->pLabelMap)
287 {
288 pMap->Next = pGlobalData->pLabelMap;
289 pGlobalData->pLabelMap = pMap;
290 }
291 else
292 {
293 pGlobalData->pLabelMap = pMap;
294 pGlobalData->pLabelMap->Next = NULL;
295 }
296 return TRUE;
297}

Referenced by LoadEventLabels().

◆ LoadEventLabels()

BOOL LoadEventLabels ( PGLOBAL_DATA  pGlobalData)

Definition at line 301 of file sounds.c.

302{
303 HKEY hSubKey;
304 DWORD dwCurKey;
306 DWORD dwName;
307 DWORD dwResult;
308 DWORD dwCount;
310 L"AppEvents\\EventLabels",
311 0,
312 KEY_READ,
313 &hSubKey) != ERROR_SUCCESS)
314 {
315 return FALSE;
316 }
317
318 dwCurKey = 0;
319 dwCount = 0;
320 do
321 {
322 dwName = _countof(szName);
323 dwResult = RegEnumKeyExW(hSubKey,
324 dwCurKey,
325 szName,
326 &dwName,
327 NULL,
328 NULL,
329 NULL,
330 NULL);
331
332 if (dwResult == ERROR_SUCCESS)
333 {
334 if (LoadEventLabel(pGlobalData, hSubKey, szName))
335 {
336 dwCount++;
337 }
338 }
339 dwCurKey++;
340
341 } while (dwResult == ERROR_SUCCESS);
342
343 RegCloseKey(hSubKey);
344 return (dwCount != 0);
345}
BOOL LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, PWCHAR szSubKey)
Definition: sounds.c:235

Referenced by SoundsDlgProc().

◆ LoadSoundFiles()

BOOL LoadSoundFiles ( HWND  hwndDlg)

Definition at line 812 of file sounds.c.

813{
814 WCHAR szList[256];
816 PWCHAR ptr;
819 LRESULT lResult;
820 UINT length;
821
822 /* Add no sound listview item */
823 if (LoadStringW(hApplet, IDS_NO_SOUND, szList, _countof(szList)))
824 {
825 szList[_countof(szList) - 1] = UNICODE_NULL;
827 }
828
829 /* Load sound files */
831 if (length == 0 || length >= _countof(szPath) - CONST_STR_LEN(L"\\media\\*"))
832 {
833 return FALSE;
834 }
835
836 //PathCchAppend(szPath, _countof(szPath), L"media\\*");
837 StringCchCatW(szPath, _countof(szPath), L"\\media\\*");
838
841 {
842 return FALSE;
843 }
844
845 do
846 {
847 if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
848 continue;
849
850 ptr = wcsrchr(FileData.cFileName, L'\\');
851 if (ptr)
852 {
853 ptr++;
854 }
855 else
856 {
857 ptr = FileData.cFileName;
858 }
859 lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, 0, (LPARAM)ptr);
860 if (lResult != CB_ERR)
861 {
862 StringCchCopyW(szPath + (length + CONST_STR_LEN(L"\\media\\")),
863 _countof(szPath) - (length + CONST_STR_LEN(L"\\media\\")),
864 FileData.cFileName);
866 }
867 } while (FindNextFileW(hFile, &FileData) != 0);
868
870 return TRUE;
871}
static FILEDATA FileData[MAX_FDS]
Definition: fs.c:51
#define IDS_NO_SOUND
Definition: resource.h:90
#define wcsrchr
Definition: compat.h:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define CONST_STR_LEN(str)
Definition: mmsys.h:23
LPCWSTR szPath
Definition: env.c:37
static PVOID ptr
Definition: dispmode.c:27
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_SETITEMDATA
Definition: winuser.h:1956
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_ADDSTRING
Definition: winuser.h:1926

Referenced by SoundsDlgProc().

◆ LoadSoundProfiles()

BOOL LoadSoundProfiles ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg 
)

Definition at line 784 of file sounds.c.

785{
786 HKEY hSubKey;
787 DWORD dwNumSchemes;
788
790 L"AppEvents\\Schemes",
791 0,
792 KEY_READ,
793 &hSubKey) != ERROR_SUCCESS)
794 {
795 return FALSE;
796 }
797
798 dwNumSchemes = EnumerateSoundProfiles(pGlobalData, hwndDlg, hSubKey);
799
800
801 if (dwNumSchemes)
802 {
803 ImportSoundProfiles(pGlobalData, hwndDlg, hSubKey);
804 }
805
806 RegCloseKey(hSubKey);
807 return FALSE;
808}
DWORD EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
Definition: sounds.c:409
BOOL ImportSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
Definition: sounds.c:741

Referenced by SoundsDlgProc().

◆ MakeFilter()

LPWSTR MakeFilter ( LPWSTR  psz)

Definition at line 64 of file sounds.c.

65{
66 PWCHAR pch;
67
68 ASSERT(psz[0] != UNICODE_NULL &&
69 psz[wcslen(psz) - 1] == L'|');
70 for (pch = psz; *pch != UNICODE_NULL; pch++)
71 {
72 /* replace vertical bar with NULL */
73 if (*pch == L'|')
74 {
76 }
77 }
78 return psz;
79}
#define pch(ap)
Definition: match.c:418

Referenced by SoundsDlgProc().

◆ RemoveLabel()

VOID RemoveLabel ( PGLOBAL_DATA  pGlobalData,
PLABEL_MAP  pMap 
)

Definition at line 126 of file sounds.c.

127{
128 PLABEL_MAP pCurMap = pGlobalData->pLabelMap;
129
130 if (pCurMap == pMap)
131 {
132 pGlobalData->pLabelMap = pGlobalData->pLabelMap->Next;
133 return;
134 }
135
136 while (pCurMap)
137 {
138 if (pCurMap->Next == pMap)
139 {
140 pCurMap->Next = pCurMap->Next->Next;
141 return;
142 }
143 pCurMap = pCurMap->Next;
144 }
145}
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)

Referenced by ImportSoundEntry().

◆ ShowSoundScheme()

BOOL ShowSoundScheme ( PGLOBAL_DATA  pGlobalData,
HWND  hwndDlg 
)

Definition at line 927 of file sounds.c.

928{
929 LRESULT lIndex;
930 PSOUND_SCHEME_CONTEXT pScheme;
931 PAPP_MAP pAppMap;
932 PLABEL_MAP pLabelMap;
933 PLABEL_CONTEXT pLabelContext;
934 HWND hDlgCtrl, hList;
935 TVINSERTSTRUCTW tvItem;
936 HTREEITEM hTreeItem;
937
938 hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
939 hList = GetDlgItem(hwndDlg, IDC_SCHEME_LIST);
940
941 if (pGlobalData->hSoundsImageList != NULL)
942 {
944 }
945
946 lIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
947 if (lIndex == CB_ERR)
948 {
949 return FALSE;
950 }
951
952 lIndex = SendMessageW(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, 0);
953 if (lIndex == CB_ERR)
954 {
955 return FALSE;
956 }
957 pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
958
959 StringCchCopyW(pGlobalData->szDefault, _countof(pGlobalData->szDefault), pScheme->szName);
960
961 pAppMap = pGlobalData->pAppMap;
962 while (pAppMap)
963 {
964 ZeroMemory(&tvItem, sizeof(tvItem));
965 tvItem.hParent = TVI_ROOT;
966 tvItem.hInsertAfter = TVI_FIRST;
967
969 tvItem.item.state = TVIS_EXPANDED;
970 tvItem.item.stateMask = TVIS_EXPANDED;
971 tvItem.item.pszText = pAppMap->szDesc;
972 tvItem.item.iImage = IMAGE_SOUND_SECTION;
973 tvItem.item.iSelectedImage = IMAGE_SOUND_SECTION;
974 tvItem.item.lParam = (LPARAM)NULL;
975
976 hTreeItem = TreeView_InsertItem(hList, &tvItem);
977
978 pLabelMap = pAppMap->LabelMap;
979 while (pLabelMap)
980 {
981 pLabelContext = FindLabelContext(pGlobalData, pScheme, pAppMap->szName, pLabelMap->szName);
982
983 ZeroMemory(&tvItem, sizeof(tvItem));
984 tvItem.hParent = hTreeItem;
985 tvItem.hInsertAfter = TVI_SORT;
986
988 tvItem.item.state = TVIS_EXPANDED;
989 tvItem.item.stateMask = TVIS_EXPANDED;
990 tvItem.item.pszText = pLabelMap->szDesc;
991 if (pLabelContext->szValue && wcslen(pLabelContext->szValue) > 0)
992 {
993 tvItem.item.iImage = IMAGE_SOUND_ASSIGNED;
994 tvItem.item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
995 }
996 else
997 {
998 tvItem.item.iImage = IMAGE_SOUND_NONE;
999 tvItem.item.iSelectedImage = IMAGE_SOUND_NONE;
1000 }
1001 tvItem.item.lParam = (LPARAM)FindLabelContext(pGlobalData, pScheme, pAppMap->szName, pLabelMap->szName);
1002
1003 TreeView_InsertItem(hList, &tvItem);
1004
1005 pLabelMap = pLabelMap->Next;
1006 }
1007 pAppMap = pAppMap->Next;
1008 }
1009 return TRUE;
1010}
#define IMAGE_SOUND_NONE
Definition: resource.h:96
#define IMAGE_SOUND_ASSIGNED
Definition: resource.h:95
#define IDC_SCHEME_LIST
Definition: resource.h:39
#define IMAGE_SOUND_SECTION
Definition: resource.h:94
HWND hList
Definition: livecd.c:10
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define TVI_FIRST
Definition: commctrl.h:3369
#define TVI_ROOT
Definition: commctrl.h:3368
#define TVIS_EXPANDED
Definition: commctrl.h:3284
#define TVI_SORT
Definition: commctrl.h:3371
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TVIF_STATE
Definition: commctrl.h:3269
HIMAGELIST hSoundsImageList
Definition: sounds.c:56
HTREEITEM hParent
Definition: commctrl.h:3393
HTREEITEM hInsertAfter
Definition: commctrl.h:3394
#define ZeroMemory
Definition: winbase.h:1670

Referenced by SoundsDlgProc().

◆ SoundsDlgProc()

INT_PTR CALLBACK SoundsDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Should store in current member

Definition at line 1146 of file sounds.c.

1150{
1151 PGLOBAL_DATA pGlobalData;
1152
1155 WCHAR szFilter[256], szTitle[256];
1156 LPWSTR pFileName;
1157 LRESULT lResult;
1158
1159 pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
1160
1161 switch (uMsg)
1162 {
1163 case WM_INITDIALOG:
1164 {
1166 SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
1167
1168 pGlobalData->NumWavOut = waveOutGetNumDevs();
1169
1173
1178 IMAGE_ICON);
1179
1180 LoadEventLabels(pGlobalData);
1181 LoadSoundProfiles(pGlobalData, hwndDlg);
1182 LoadSoundFiles(hwndDlg);
1183 ShowSoundScheme(pGlobalData, hwndDlg);
1184
1185 if (wParam == (WPARAM)GetDlgItem(hwndDlg, IDC_SOUND_SCHEME))
1186 return TRUE;
1188 return FALSE;
1189 }
1190 case WM_COMMAND:
1191 {
1192 switch (LOWORD(wParam))
1193 {
1194 case IDC_BROWSE_SOUND:
1195 {
1196 ZeroMemory(&ofn, sizeof(ofn));
1197 ofn.lStructSize = sizeof(ofn);
1198 ofn.hwndOwner = hwndDlg;
1204 ofn.nFilterIndex = 0;
1207 ofn.lpstrInitialDir = L"%SystemRoot%\\Media";
1209
1210 if (GetOpenFileNameW(&ofn))
1211 {
1212 // search if list already contains that sound
1213 lResult = FindSoundFileInList(hwndDlg, filename);
1214 if (lResult != CB_ERR)
1215 {
1216 SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETCURSEL, (WPARAM)lResult, 0);
1217 break;
1218 }
1219
1220 // extract file name
1221 pFileName = wcsrchr(filename, L'\\');
1222 ASSERT(pFileName != NULL);
1223 pFileName++;
1224
1225 // add to list
1226 lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, 0, (LPARAM)pFileName);
1227 if (lResult != CB_ERR)
1228 {
1229 // add path and select item
1231 SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETCURSEL, (WPARAM)lResult, 0);
1232 }
1233 }
1234 break;
1235 }
1236 case IDC_PLAY_SOUND:
1237 {
1238 LRESULT lIndex;
1239 lIndex = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1240 if (lIndex == CB_ERR)
1241 {
1242 break;
1243 }
1244
1245 lIndex = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1246 if (lIndex != CB_ERR)
1247 {
1249 }
1250 break;
1251 }
1252 case IDC_SOUND_SCHEME:
1253 {
1254 if (HIWORD(wParam) == CBN_SELENDOK)
1255 {
1257 ShowSoundScheme(pGlobalData, hwndDlg);
1262 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1263 }
1264 break;
1265 }
1266 case IDC_SOUND_LIST:
1267 {
1268 if (HIWORD(wParam) == CBN_SELENDOK)
1269 {
1270 PLABEL_CONTEXT pLabelContext;
1272 TVITEMW item;
1273 LRESULT lIndex;
1274
1276 if (hItem == NULL)
1277 {
1278 break;
1279 }
1280
1281 lIndex = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1282 if (lIndex == CB_ERR)
1283 {
1284 break;
1285 }
1286
1287 ZeroMemory(&item, sizeof(item));
1288 item.mask = TVIF_PARAM;
1289 item.hItem = hItem;
1291 {
1292 LRESULT lResult;
1293 pLabelContext = (PLABEL_CONTEXT)item.lParam;
1294
1295 lResult = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1296 if (lResult == CB_ERR || lResult == 0)
1297 {
1298 if (lIndex != pLabelContext->szValue[0])
1299 {
1300 /* Update the tree view item image */
1302 item.iImage = IMAGE_SOUND_NONE;
1303 item.iSelectedImage = IMAGE_SOUND_NONE;
1305
1306 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1307
1309 }
1310
1311 pLabelContext->szValue[0] = UNICODE_NULL;
1312
1313 break;
1314 }
1315
1316 if (_wcsicmp(pLabelContext->szValue, (PWCHAR)lResult) || (lIndex != pLabelContext->szValue[0]))
1317 {
1318 /* Update the tree view item image */
1320 item.iImage = IMAGE_SOUND_ASSIGNED;
1321 item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
1323
1324 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1325
1329 StringCchCopyW(pLabelContext->szValue, _countof(pLabelContext->szValue), (PWCHAR)lResult);
1330 }
1331
1332 if (wcslen((PWCHAR)lResult) && lIndex != 0 && pGlobalData->NumWavOut != 0)
1333 {
1335 }
1336 else
1337 {
1339 }
1340 }
1341 }
1342 break;
1343 }
1344 }
1345 break;
1346 }
1347 case WM_DESTROY:
1348 {
1349 FreeSoundFiles(hwndDlg);
1350 FreeSoundProfiles(hwndDlg);
1351 FreeAppMap(pGlobalData);
1352 FreeLabelMap(pGlobalData);
1353 if (pGlobalData->hSoundsImageList)
1354 ImageList_Destroy(pGlobalData->hSoundsImageList);
1355 HeapFree(GetProcessHeap(), 0, pGlobalData);
1356 break;
1357 }
1358 case WM_NOTIFY:
1359 {
1360 PLABEL_CONTEXT pLabelContext;
1361 PWCHAR ptr;
1362
1363 LPNMHDR lpnm = (LPNMHDR)lParam;
1364
1365 switch (lpnm->code)
1366 {
1367 case PSN_APPLY:
1368 {
1369 ApplyChanges(hwndDlg);
1370 break;
1371 }
1372 case TVN_SELCHANGED:
1373 {
1375 LRESULT lCount, lIndex, lResult;
1376
1377 pLabelContext = (PLABEL_CONTEXT)nm->itemNew.lParam;
1378 if (pLabelContext == NULL)
1379 {
1384 return FALSE;
1385 }
1386
1390
1391 if (wcslen(pLabelContext->szValue) == 0)
1392 {
1393 lIndex = ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), 0);
1395 break;
1396 }
1397
1398 if (pGlobalData->NumWavOut != 0)
1400
1401 lCount = ComboBox_GetCount(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1402 for (lIndex = 0; lIndex < lCount; lIndex++)
1403 {
1404 lResult = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1405 if (lResult == CB_ERR || lResult == 0)
1406 continue;
1407
1408 if (!wcscmp((PWCHAR)lResult, pLabelContext->szValue))
1409 {
1410 ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1411 return FALSE;
1412 }
1413 }
1414
1415 ptr = wcsrchr(pLabelContext->szValue, L'\\');
1416 if (ptr)
1417 {
1418 ptr++;
1419 }
1420 else
1421 {
1422 ptr = pLabelContext->szValue;
1423 }
1424
1425 lIndex = ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST), ptr);
1426 if (lIndex != CB_ERR)
1427 {
1428 ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex, _wcsdup(pLabelContext->szValue));
1429 ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1430 }
1431 break;
1432 }
1433 }
1434 }
1435 break;
1436 }
1437
1438 return FALSE;
1439}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define IDI_SOUND_ASSIGNED
Definition: resource.h:11
#define IDI_PLAY_ICON
Definition: resource.h:5
#define IDI_SOUND_SECTION
Definition: resource.h:10
#define IDC_TEXT_SOUND
Definition: resource.h:47
#define IDC_PLAY_SOUND
Definition: resource.h:48
#define IDS_WAVE_FILES_FILTER
Definition: resource.h:85
#define IDS_BROWSE_FOR_SOUND
Definition: resource.h:84
#define IDC_BROWSE_SOUND
Definition: resource.h:49
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4677
OPENFILENAME ofn
Definition: main.cpp:29
const char * filename
Definition: ioapi.h:137
if(dx< 0)
Definition: linetemp.h:194
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define SND_FILENAME
Definition: mmsystem.h:162
static ATOM item
Definition: dde.c:856
LPTSTR szFilter
Definition: mplay32.c:30
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
Definition: playsound.c:531
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
struct tagNMTREEVIEWW * LPNMTREEVIEWW
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
#define WM_NOTIFY
Definition: richedit.h:61
struct _GLOBAL_DATA GLOBAL_DATA
BOOL LoadSoundFiles(HWND hwndDlg)
Definition: sounds.c:812
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
Definition: sounds.c:1083
LPWSTR MakeFilter(LPWSTR psz)
Definition: sounds.c:64
static LRESULT FindSoundFileInList(HWND hwndDlg, LPCWSTR pSoundPath)
Definition: sounds.c:901
BOOL LoadEventLabels(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:301
static VOID FreeAppMap(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:188
static VOID FreeSoundProfiles(HWND hwndDlg)
Definition: sounds.c:498
struct _LABEL_CONTEXT * PLABEL_CONTEXT
BOOL ApplyChanges(HWND hwndDlg)
Definition: sounds.c:1014
struct _GLOBAL_DATA * PGLOBAL_DATA
static VOID FreeLabelMap(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:149
BOOL LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
Definition: sounds.c:784
BOOL ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
Definition: sounds.c:927
static VOID FreeSoundFiles(HWND hwndDlg)
Definition: sounds.c:875
UINT NumWavOut
Definition: sounds.c:59
UINT code
Definition: winuser.h:3149
TVITEMW itemNew
Definition: commctrl.h:3638
DWORD nFilterIndex
Definition: commdlg.h:335
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
LPARAM lParam
Definition: commctrl.h:3325
HTREEITEM hItem
Definition: treelist.h:37
#define HIWORD(l)
Definition: typedefs.h:247
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:49
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
#define DWLP_USER
Definition: winuser.h:866
#define GetWindowLongPtrW
Definition: winuser.h:4819
#define WM_COMMAND
Definition: winuser.h:1730
#define CB_SETCURSEL
Definition: winuser.h:1951
#define WM_INITDIALOG
Definition: winuser.h:1729
#define BM_SETIMAGE
Definition: winuser.h:1912
#define SM_CXSMICON
Definition: winuser.h:1006
HWND WINAPI SetFocus(_In_opt_ HWND)
struct tagNMHDR * LPNMHDR
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define CBN_SELENDOK
Definition: winuser.h:1971
#define WM_DESTROY
Definition: winuser.h:1599
int WINAPI GetSystemMetrics(_In_ int)

Referenced by MmSysApplet(), and ShowFullControlPanel().