ReactOS  0.4.15-dev-5455-g015cd25
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)
 
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 
357  if (RegOpenKeyExW(hKey,
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  {
401  ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), lResult);
402  }
403 
404  return TRUE;
405 }
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:41
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define ComboBox_DeleteString(hwndCtl, index)
Definition: windowsx.h:42
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define CB_ERR
Definition: winuser.h:2425
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR szName[MAX_PATH]
Definition: sounds.c:48
#define IDC_SOUND_SCHEME
Definition: resource.h:38
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:66
#define ComboBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:69
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
WCHAR szDesc[MAX_PATH]
Definition: sounds.c:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG_PTR LRESULT
Definition: windef.h:209
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by EnumerateSoundProfiles().

◆ ApplyChanges()

BOOL ApplyChanges ( HWND  hwndDlg)

Definition at line 987 of file sounds.c.

988 {
989  HKEY hKey, hSubKey;
990  DWORD dwType;
991  LRESULT lIndex;
992  PSOUND_SCHEME_CONTEXT pScheme;
993  HWND hDlgCtrl;
994  PLABEL_CONTEXT pLabelContext;
995  WCHAR Buffer[100];
996 
997  hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
998 
999  lIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
1000  if (lIndex == CB_ERR)
1001  {
1002  return FALSE;
1003  }
1004 
1005  lIndex = SendMessageW(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, 0);
1006  if (lIndex == CB_ERR)
1007  {
1008  return FALSE;
1009  }
1010  pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
1011 
1013  L"AppEvents\\Schemes",
1014  0,
1015  KEY_WRITE,
1016  &hKey) != ERROR_SUCCESS)
1017  {
1018  return FALSE;
1019  }
1020 
1021  RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pScheme->szName, (wcslen(pScheme->szName) + 1) * sizeof(WCHAR));
1022  RegCloseKey(hKey);
1023 
1025  L"AppEvents\\Schemes\\Apps",
1026  0,
1027  KEY_WRITE,
1028  &hKey) != ERROR_SUCCESS)
1029  {
1030  return FALSE;
1031  }
1032 
1033  pLabelContext = pScheme->LabelContext;
1034 
1035  while (pLabelContext)
1036  {
1037  StringCchPrintfW(Buffer, _countof(Buffer), L"%s\\%s\\.Current", pLabelContext->AppMap->szName, pLabelContext->LabelMap->szName);
1038 
1039  if (RegOpenKeyExW(hKey, Buffer, 0, KEY_WRITE, &hSubKey) == ERROR_SUCCESS)
1040  {
1041  dwType = (wcschr(pLabelContext->szValue, L'%') ? REG_EXPAND_SZ : REG_SZ);
1042  RegSetValueExW(hSubKey, NULL, 0, dwType, (LPBYTE)pLabelContext->szValue, (wcslen(pLabelContext->szValue) + 1) * sizeof(WCHAR));
1043  RegCloseKey(hSubKey);
1044  }
1045 
1046  pLabelContext = pLabelContext->Next;
1047  }
1048  RegCloseKey(hKey);
1049 
1051  return TRUE;
1052 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PWCHAR szName
Definition: sounds.c:21
#define TRUE
Definition: types.h:120
#define CB_GETITEMDATA
Definition: winuser.h:1940
#define HKEY_CURRENT_USER
Definition: winreg.h:11
PLABEL_CONTEXT LabelContext
Definition: sounds.c:50
struct _LABEL_CONTEXT * Next
Definition: sounds.c:43
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_GETCURSEL
Definition: winuser.h:1933
#define DWLP_MSGRESULT
Definition: winuser.h:864
#define L(x)
Definition: ntvdm.h:50
PLABEL_MAP LabelMap
Definition: sounds.c:40
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
PAPP_MAP AppMap
Definition: sounds.c:41
Definition: bufpool.h:45
struct _SOUND_SCHEME_CONTEXT * PSOUND_SCHEME_CONTEXT
#define CB_ERR
Definition: winuser.h:2425
#define KEY_WRITE
Definition: nt_native.h:1031
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:4899
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PSNRET_NOERROR
Definition: prsht.h:129
WCHAR szName[MAX_PATH]
Definition: sounds.c:48
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
#define IDC_SOUND_SCHEME
Definition: resource.h:38
FxAutoRegKey hKey
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR szValue[MAX_PATH]
Definition: sounds.c:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define SetWindowLongPtrW
Definition: winuser.h:5336
LONG_PTR LRESULT
Definition: windef.h:209
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_SZ
Definition: layer.c:22

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 
427  if (RegOpenKeyExW(hKey,
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 }
static const WCHAR szName[]
Definition: powrprof.c:45
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
WCHAR szDefault[MAX_PATH]
Definition: sounds.c:55
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
BOOL AddSoundProfile(HWND hwndDlg, HKEY hKey, PWCHAR szSubKey, BOOL SetDefault)
Definition: sounds.c:349
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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
#define RegCloseKey(hKey)
Definition: registry.h:47
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

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 }
static const WCHAR szName[]
Definition: powrprof.c:45
PAPP_MAP pAppMap
Definition: sounds.c:58
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
_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
#define NULL
Definition: types.h:112

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 }
static const WCHAR szName[]
Definition: powrprof.c:45
PLABEL_MAP LabelMap
Definition: sounds.c:35
PWCHAR szName
Definition: sounds.c:21
struct _LABEL_MAP * Next
Definition: sounds.c:25
PWCHAR szDesc
Definition: sounds.c:22
struct _APP_MAP * AppMap
Definition: sounds.c:24
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ASSERT(a)
Definition: mode.c:44
PLABEL_MAP pLabelMap
Definition: sounds.c:57
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:735

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 }
PWCHAR szName
Definition: sounds.c:21
PLABEL_CONTEXT LabelContext
Definition: sounds.c:50
struct _LABEL_CONTEXT * Next
Definition: sounds.c:43
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
PAPP_MAP FindApp(PGLOBAL_DATA pGlobalData, PWCHAR szName)
Definition: sounds.c:171
PLABEL_MAP LabelMap
Definition: sounds.c:40
#define UNICODE_NULL
PAPP_MAP AppMap
Definition: sounds.c:41
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ASSERT(a)
Definition: mode.c:44
PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, PWCHAR szName)
Definition: sounds.c:81
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
WCHAR szValue[MAX_PATH]
Definition: sounds.c:42
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by ImportSoundLabel(), and ShowSoundScheme().

◆ 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 }
static const WCHAR szName[]
Definition: powrprof.c:45
struct _SOUND_SCHEME_CONTEXT * PSOUND_SCHEME_CONTEXT
#define CB_ERR
Definition: winuser.h:2425
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:48
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:54
WCHAR szName[MAX_PATH]
Definition: sounds.c:48
#define IDC_SOUND_SCHEME
Definition: resource.h:38
#define NULL
Definition: types.h:112
LONG_PTR LRESULT
Definition: windef.h:209
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

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 }
PAPP_MAP pAppMap
Definition: sounds.c:58
#define GetProcessHeap()
Definition: compat.h:736
struct _APP_MAP * Next
Definition: sounds.c:34
#define HeapFree(x, y, z)
Definition: compat.h:735

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 }
PWCHAR szName
Definition: sounds.c:21
#define free
Definition: debug_ros.c:5
struct _LABEL_MAP * Next
Definition: sounds.c:25
PWCHAR szDesc
Definition: sounds.c:22
PWCHAR szIcon
Definition: sounds.c:23
#define GetProcessHeap()
Definition: compat.h:736
PLABEL_MAP pLabelMap
Definition: sounds.c:57
#define HeapFree(x, y, z)
Definition: compat.h:735

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 }
#define free
Definition: debug_ros.c:5
#define IDC_SOUND_LIST
Definition: resource.h:40
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CB_ERR
Definition: winuser.h:2425
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:48
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:54
LONG_PTR LRESULT
Definition: windef.h:209

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 }
PLABEL_CONTEXT LabelContext
Definition: sounds.c:50
struct _LABEL_CONTEXT * Next
Definition: sounds.c:43
struct _SOUND_SCHEME_CONTEXT * PSOUND_SCHEME_CONTEXT
#define CB_ERR
Definition: winuser.h:2425
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:48
#define GetProcessHeap()
Definition: compat.h:736
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:54
#define IDC_SOUND_SCHEME
Definition: resource.h:38
LONG_PTR LRESULT
Definition: windef.h:209
#define HeapFree(x, y, z)
Definition: compat.h:735

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 
669  if (RegOpenKeyExW(hKey,
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 }
WCHAR szIcon[MAX_PATH]
Definition: sounds.c:32
static const WCHAR szName[]
Definition: powrprof.c:45
#define ERROR_SUCCESS
Definition: deptool.c:10
PAPP_MAP pAppMap
Definition: sounds.c:58
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define UNICODE_NULL
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
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
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
TCHAR szAppName[128]
Definition: solitaire.cpp:17
FxAutoRegKey hKey
struct _APP_MAP * Next
Definition: sounds.c:34
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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
#define HeapFree(x, y, z)
Definition: compat.h:735
#define RegCloseKey(hKey)
Definition: registry.h:47

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 
603  if (RegOpenKeyExW(hKey,
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 }
PLABEL_MAP LabelMap
Definition: sounds.c:35
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID RemoveLabel(PGLOBAL_DATA pGlobalData, PLABEL_MAP pMap)
Definition: sounds.c:126
#define KEY_READ
Definition: nt_native.h:1023
struct _LABEL_MAP * Next
Definition: sounds.c:25
#define FALSE
Definition: types.h:117
struct _APP_MAP * AppMap
Definition: sounds.c:24
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, PWCHAR szName)
Definition: sounds.c:81
TCHAR szAppName[128]
Definition: solitaire.cpp:17
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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
#define RegCloseKey(hKey)
Definition: registry.h:47

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 
545  if (RegOpenKeyExW(hKey,
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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PWCHAR szName
Definition: sounds.c:21
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT pSoundScheme, PWCHAR AppName, PWCHAR LabelName)
Definition: sounds.c:200
WCHAR szDefault[MAX_PATH]
Definition: sounds.c:55
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
WCHAR szValue[MAX_PATH]
Definition: sounds.c:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
PSOUND_SCHEME_CONTEXT FindSoundProfile(HWND hwndDlg, PWCHAR szName)
Definition: sounds.c:466
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

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 
749  if (RegOpenKeyExW(hKey,
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,
765  _countof(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 }
static const WCHAR szName[]
Definition: powrprof.c:45
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
DWORD ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szAppName)
Definition: sounds.c:652
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
FxAutoRegKey hKey
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by LoadSoundProfiles().

◆ InitImageList()

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

Definition at line 1056 of file sounds.c.

1061 {
1062  HANDLE hImage;
1063  HIMAGELIST himl;
1064  UINT i;
1065  INT ret;
1066 
1067  /* Create the toolbar icon image list */
1069  Height,
1071  EndResource - StartResource,
1072  0);
1073  if (himl == NULL)
1074  return NULL;
1075 
1076  ret = 0;
1077  for (i = StartResource; i <= EndResource && ret != -1; i++)
1078  {
1079  hImage = LoadImageW(hApplet,
1081  type,
1082  Width,
1083  Height,
1085  if (hImage == NULL)
1086  {
1087  ret = -1;
1088  break;
1089  }
1090 
1091  if (type == IMAGE_BITMAP)
1092  {
1094  hImage,
1095  RGB(255, 0, 128));
1096  }
1097  else if (type == IMAGE_ICON)
1098  {
1100  hImage);
1101  }
1102 
1103  DeleteObject(hImage);
1104  }
1105 
1106  if (ret == -1)
1107  {
1109  himl = NULL;
1110  }
1111 
1112  return himl;
1113 }
#define IMAGE_ICON
Definition: winuser.h:212
#define RGB(r, g, b)
Definition: precomp.h:62
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:124
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HINSTANCE hApplet
Definition: access.c:17
_In_ HFONT _Out_ PUINT Height
Definition: font.h:124
HIMAGELIST himl
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
#define ILC_COLOR32
Definition: commctrl.h:358
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
int ret
#define LR_LOADTRANSPARENT
Definition: winuser.h:1087
#define ILC_MASK
Definition: commctrl.h:351
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 NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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 
243  if (RegOpenKeyExW(hKey,
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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PWCHAR szName
Definition: sounds.c:21
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
struct _LABEL_MAP * Next
Definition: sounds.c:25
PWCHAR szDesc
Definition: sounds.c:22
PWCHAR szIcon
Definition: sounds.c:23
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
PLABEL_MAP pLabelMap
Definition: sounds.c:57
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define RegCloseKey(hKey)
Definition: registry.h:47

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 }
static const WCHAR szName[]
Definition: powrprof.c:45
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define L(x)
Definition: ntvdm.h:50
BOOL LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, PWCHAR szSubKey)
Definition: sounds.c:235
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by SoundsDlgProc().

◆ LoadSoundFiles()

BOOL LoadSoundFiles ( HWND  hwndDlg)

Definition at line 812 of file sounds.c.

813 {
814  WCHAR szList[256];
816  PWCHAR ptr;
818  HANDLE hFile;
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;
826  ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST), szList);
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 
869  FindClose(hFile);
870  return TRUE;
871 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define CB_SETITEMDATA
Definition: winuser.h:1956
static FILEDATA FileData[MAX_FDS]
Definition: fs.c:51
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:41
#define TRUE
Definition: types.h:120
#define IDC_SOUND_LIST
Definition: resource.h:40
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
uint16_t * PWCHAR
Definition: typedefs.h:56
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IDS_NO_SOUND
Definition: resource.h:90
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static PVOID ptr
Definition: dispmode.c:27
#define CB_ADDSTRING
Definition: winuser.h:1926
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ERR
Definition: winuser.h:2425
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define wcsrchr
Definition: compat.h:16
_In_ HANDLE hFile
Definition: mswsock.h:90
LPCWSTR szPath
Definition: env.c:37
unsigned int UINT
Definition: ndis.h:50
LONG_PTR LRESULT
Definition: windef.h:209
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define CONST_STR_LEN(str)
Definition: mmsys.h:23
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL ImportSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
Definition: sounds.c:741
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
DWORD EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey)
Definition: sounds.c:409
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define RegCloseKey(hKey)
Definition: registry.h:47

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  {
75  *pch = UNICODE_NULL;
76  }
77  }
78  return psz;
79 }
uint16_t * PWCHAR
Definition: typedefs.h:56
#define pch(ap)
Definition: match.c:418
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
#define ASSERT(a)
Definition: mode.c:44
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 }
struct _LABEL_MAP * Next
Definition: sounds.c:25
PLABEL_MAP pLabelMap
Definition: sounds.c:57
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 900 of file sounds.c.

901 {
902  LRESULT lIndex;
903  PSOUND_SCHEME_CONTEXT pScheme;
904  PAPP_MAP pAppMap;
905  PLABEL_MAP pLabelMap;
906  PLABEL_CONTEXT pLabelContext;
907  HWND hDlgCtrl, hList;
908  TVINSERTSTRUCTW tvItem;
909  HTREEITEM hTreeItem;
910 
911  hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
912  hList = GetDlgItem(hwndDlg, IDC_SCHEME_LIST);
913 
914  if (pGlobalData->hSoundsImageList != NULL)
915  {
917  }
918 
919  lIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
920  if (lIndex == CB_ERR)
921  {
922  return FALSE;
923  }
924 
925  lIndex = SendMessageW(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, 0);
926  if (lIndex == CB_ERR)
927  {
928  return FALSE;
929  }
930  pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
931 
932  StringCchCopyW(pGlobalData->szDefault, _countof(pGlobalData->szDefault), pScheme->szName);
933 
934  pAppMap = pGlobalData->pAppMap;
935  while (pAppMap)
936  {
937  ZeroMemory(&tvItem, sizeof(tvItem));
938  tvItem.hParent = TVI_ROOT;
939  tvItem.hInsertAfter = TVI_FIRST;
940 
942  tvItem.item.state = TVIS_EXPANDED;
943  tvItem.item.stateMask = TVIS_EXPANDED;
944  tvItem.item.pszText = pAppMap->szDesc;
945  tvItem.item.iImage = IMAGE_SOUND_SECTION;
946  tvItem.item.iSelectedImage = IMAGE_SOUND_SECTION;
947  tvItem.item.lParam = (LPARAM)NULL;
948 
949  hTreeItem = TreeView_InsertItem(hList, &tvItem);
950 
951  pLabelMap = pAppMap->LabelMap;
952  while (pLabelMap)
953  {
954  pLabelContext = FindLabelContext(pGlobalData, pScheme, pAppMap->szName, pLabelMap->szName);
955 
956  ZeroMemory(&tvItem, sizeof(tvItem));
957  tvItem.hParent = hTreeItem;
958  tvItem.hInsertAfter = TVI_SORT;
959 
961  tvItem.item.state = TVIS_EXPANDED;
962  tvItem.item.stateMask = TVIS_EXPANDED;
963  tvItem.item.pszText = pLabelMap->szDesc;
964  if (pLabelContext->szValue && wcslen(pLabelContext->szValue) > 0)
965  {
966  tvItem.item.iImage = IMAGE_SOUND_ASSIGNED;
967  tvItem.item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
968  }
969  else
970  {
971  tvItem.item.iImage = IMAGE_SOUND_NONE;
972  tvItem.item.iSelectedImage = IMAGE_SOUND_NONE;
973  }
974  tvItem.item.lParam = (LPARAM)FindLabelContext(pGlobalData, pScheme, pAppMap->szName, pLabelMap->szName);
975 
976  TreeView_InsertItem(hList, &tvItem);
977 
978  pLabelMap = pLabelMap->Next;
979  }
980  pAppMap = pAppMap->Next;
981  }
982  return TRUE;
983 }
HTREEITEM hParent
Definition: commctrl.h:3393
PLABEL_MAP LabelMap
Definition: sounds.c:35
PWCHAR szName
Definition: sounds.c:21
PAPP_MAP pAppMap
Definition: sounds.c:58
#define TRUE
Definition: types.h:120
#define CB_GETITEMDATA
Definition: winuser.h:1940
HIMAGELIST hSoundsImageList
Definition: sounds.c:56
struct _LABEL_MAP * Next
Definition: sounds.c:25
#define TVI_SORT
Definition: commctrl.h:3371
#define ZeroMemory
Definition: winbase.h:1670
PWCHAR szDesc
Definition: sounds.c:22
#define IMAGE_SOUND_SECTION
Definition: resource.h:94
UINT_PTR WPARAM
Definition: windef.h:207
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define CB_GETCURSEL
Definition: winuser.h:1933
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define FALSE
Definition: types.h:117
HTREEITEM hInsertAfter
Definition: commctrl.h:3394
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define TVI_FIRST
Definition: commctrl.h:3369
LONG_PTR LPARAM
Definition: windef.h:208
struct _SOUND_SCHEME_CONTEXT * PSOUND_SCHEME_CONTEXT
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT pSoundScheme, PWCHAR AppName, PWCHAR LabelName)
Definition: sounds.c:200
WCHAR szDefault[MAX_PATH]
Definition: sounds.c:55
#define CB_ERR
Definition: winuser.h:2425
#define IDC_SCHEME_LIST
Definition: resource.h:39
WCHAR szDesc[MAX_PATH]
Definition: sounds.c:31
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define _countof(array)
Definition: sndvol32.h:68
#define IMAGE_SOUND_NONE
Definition: resource.h:96
#define IMAGE_SOUND_ASSIGNED
Definition: resource.h:95
#define TVI_ROOT
Definition: commctrl.h:3368
WCHAR szName[MAX_PATH]
Definition: sounds.c:48
WCHAR szName[MAX_PATH]
Definition: sounds.c:30
#define IDC_SOUND_SCHEME
Definition: resource.h:38
#define TVIS_EXPANDED
Definition: commctrl.h:3284
HWND hList
Definition: livecd.c:10
#define TVIF_TEXT
Definition: commctrl.h:3266
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct _APP_MAP * Next
Definition: sounds.c:34
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR szValue[MAX_PATH]
Definition: sounds.c:42
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define TVIF_STATE
Definition: commctrl.h:3269
#define TVIF_PARAM
Definition: commctrl.h:3268
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by SoundsDlgProc().

◆ SoundsDlgProc()

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

Should store in current member

Definition at line 1119 of file sounds.c.

1123 {
1124  PGLOBAL_DATA pGlobalData;
1125 
1128  WCHAR szFilter[256], szTitle[256];
1129  LPWSTR pFileName;
1130  LRESULT lResult;
1131 
1132  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
1133 
1134  switch (uMsg)
1135  {
1136  case WM_INITDIALOG:
1137  {
1139  SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
1140 
1141  pGlobalData->NumWavOut = waveOutGetNumDevs();
1142 
1146 
1151  IMAGE_ICON);
1152 
1153  LoadEventLabels(pGlobalData);
1154  LoadSoundProfiles(pGlobalData, hwndDlg);
1155  LoadSoundFiles(hwndDlg);
1156  ShowSoundScheme(pGlobalData, hwndDlg);
1157 
1158  if (wParam == (WPARAM)GetDlgItem(hwndDlg, IDC_SOUND_SCHEME))
1159  return TRUE;
1161  return FALSE;
1162  }
1163  case WM_COMMAND:
1164  {
1165  switch (LOWORD(wParam))
1166  {
1167  case IDC_BROWSE_SOUND:
1168  {
1169  ZeroMemory(&ofn, sizeof(ofn));
1170  ofn.lStructSize = sizeof(ofn);
1171  ofn.hwndOwner = hwndDlg;
1173  ofn.lpstrFile[0] = UNICODE_NULL;
1177  ofn.nFilterIndex = 0;
1180  ofn.lpstrInitialDir = L"%SystemRoot%\\Media";
1182 
1183  if (GetOpenFileNameW(&ofn))
1184  {
1185  // FIXME search if list already contains that sound
1186 
1187  // extract file name
1188  pFileName = wcsrchr(filename, L'\\');
1189  ASSERT(pFileName != NULL);
1190  pFileName++;
1191 
1192  // add to list
1193  lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, 0, (LPARAM)pFileName);
1194  if (lResult != CB_ERR)
1195  {
1196  // add path and select item
1198  SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETCURSEL, (WPARAM)lResult, 0);
1199  }
1200  }
1201  break;
1202  }
1203  case IDC_PLAY_SOUND:
1204  {
1205  LRESULT lIndex;
1206  lIndex = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1207  if (lIndex == CB_ERR)
1208  {
1209  break;
1210  }
1211 
1212  lIndex = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1213  if (lIndex != CB_ERR)
1214  {
1215  PlaySoundW((PWCHAR)lIndex, NULL, SND_FILENAME);
1216  }
1217  break;
1218  }
1219  case IDC_SOUND_SCHEME:
1220  {
1221  if (HIWORD(wParam) == CBN_SELENDOK)
1222  {
1224  ShowSoundScheme(pGlobalData, hwndDlg);
1229  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1230  }
1231  break;
1232  }
1233  case IDC_SOUND_LIST:
1234  {
1235  if (HIWORD(wParam) == CBN_SELENDOK)
1236  {
1237  PLABEL_CONTEXT pLabelContext;
1238  HTREEITEM hItem;
1239  TVITEMW item;
1240  LRESULT lIndex;
1241 
1243  if (hItem == NULL)
1244  {
1245  break;
1246  }
1247 
1248  lIndex = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1249  if (lIndex == CB_ERR)
1250  {
1251  break;
1252  }
1253 
1254  ZeroMemory(&item, sizeof(item));
1255  item.mask = TVIF_PARAM;
1256  item.hItem = hItem;
1258  {
1259  LRESULT lResult;
1260  pLabelContext = (PLABEL_CONTEXT)item.lParam;
1261 
1262  lResult = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1263  if (lResult == CB_ERR || lResult == 0)
1264  {
1265  if (lIndex != pLabelContext->szValue[0])
1266  {
1267  /* Update the tree view item image */
1269  item.iImage = IMAGE_SOUND_NONE;
1270  item.iSelectedImage = IMAGE_SOUND_NONE;
1272 
1273  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1274 
1276  }
1277 
1278  pLabelContext->szValue[0] = UNICODE_NULL;
1279 
1280  break;
1281  }
1282 
1283  if (_wcsicmp(pLabelContext->szValue, (PWCHAR)lResult) || (lIndex != pLabelContext->szValue[0]))
1284  {
1285  /* Update the tree view item image */
1287  item.iImage = IMAGE_SOUND_ASSIGNED;
1288  item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
1290 
1291  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1292 
1296  StringCchCopyW(pLabelContext->szValue, _countof(pLabelContext->szValue), (PWCHAR)lResult);
1297  }
1298 
1299  if (wcslen((PWCHAR)lResult) && lIndex != 0 && pGlobalData->NumWavOut != 0)
1300  {
1302  }
1303  else
1304  {
1306  }
1307  }
1308  }
1309  break;
1310  }
1311  }
1312  break;
1313  }
1314  case WM_DESTROY:
1315  {
1316  FreeSoundFiles(hwndDlg);
1317  FreeSoundProfiles(hwndDlg);
1318  FreeAppMap(pGlobalData);
1319  FreeLabelMap(pGlobalData);
1320  if (pGlobalData->hSoundsImageList)
1321  ImageList_Destroy(pGlobalData->hSoundsImageList);
1322  HeapFree(GetProcessHeap(), 0, pGlobalData);
1323  break;
1324  }
1325  case WM_NOTIFY:
1326  {
1327  PLABEL_CONTEXT pLabelContext;
1328  PWCHAR ptr;
1329 
1330  LPNMHDR lpnm = (LPNMHDR)lParam;
1331 
1332  switch (lpnm->code)
1333  {
1334  case PSN_APPLY:
1335  {
1336  ApplyChanges(hwndDlg);
1337  break;
1338  }
1339  case TVN_SELCHANGED:
1340  {
1342  LRESULT lCount, lIndex, lResult;
1343 
1344  pLabelContext = (PLABEL_CONTEXT)nm->itemNew.lParam;
1345  if (pLabelContext == NULL)
1346  {
1351  return FALSE;
1352  }
1353 
1357 
1358  if (wcslen(pLabelContext->szValue) == 0)
1359  {
1360  lIndex = ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), 0);
1362  break;
1363  }
1364 
1365  if (pGlobalData->NumWavOut != 0)
1367 
1368  lCount = ComboBox_GetCount(GetDlgItem(hwndDlg, IDC_SOUND_LIST));
1369  for (lIndex = 0; lIndex < lCount; lIndex++)
1370  {
1371  lResult = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1372  if (lResult == CB_ERR || lResult == 0)
1373  continue;
1374 
1375  if (!wcscmp((PWCHAR)lResult, pLabelContext->szValue))
1376  {
1377  ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1378  return FALSE;
1379  }
1380  }
1381 
1382  ptr = wcsrchr(pLabelContext->szValue, L'\\');
1383  if (ptr)
1384  {
1385  ptr++;
1386  }
1387  else
1388  {
1389  ptr = pLabelContext->szValue;
1390  }
1391 
1392  lIndex = ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST), ptr);
1393  if (lIndex != CB_ERR)
1394  {
1395  ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex, _wcsdup(pLabelContext->szValue));
1396  ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
1397  }
1398  break;
1399  }
1400  }
1401  }
1402  break;
1403  }
1404 
1405  return FALSE;
1406 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
#define CB_SETITEMDATA
Definition: winuser.h:1956
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
Definition: sounds.c:1056
#define IDC_PLAY_SOUND
Definition: resource.h:48
BOOL LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
Definition: sounds.c:784
#define IMAGE_ICON
Definition: winuser.h:212
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:41
#define IDI_SOUND_ASSIGNED
Definition: resource.h:11
HWND hwndOwner
Definition: commdlg.h:330
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
#define IDS_BROWSE_FOR_SOUND
Definition: resource.h:84
#define TRUE
Definition: types.h:120
BOOL ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
Definition: sounds.c:900
BOOL ApplyChanges(HWND hwndDlg)
Definition: sounds.c:987
HIMAGELIST hSoundsImageList
Definition: sounds.c:56
LPARAM lParam
Definition: commctrl.h:3325
OPENFILENAME ofn
Definition: main.cpp:37
BOOL LoadSoundFiles(HWND hwndDlg)
Definition: sounds.c:812
#define IDC_SOUND_LIST
Definition: resource.h:40
#define ZeroMemory
Definition: winbase.h:1670
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:49
HWND WINAPI SetFocus(_In_opt_ HWND)
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4819
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
uint16_t * PWCHAR
Definition: typedefs.h:56
#define PSN_APPLY
Definition: prsht.h:117
if(dx==0 &&dy==0)
Definition: linetemp.h:174
const char * filename
Definition: ioapi.h:137
#define BM_SETIMAGE
Definition: winuser.h:1912
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
DWORD nMaxFile
Definition: commdlg.h:337
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
UINT code
Definition: winuser.h:3149
struct _LABEL_CONTEXT * PLABEL_CONTEXT
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
LPWSTR MakeFilter(LPWSTR psz)
Definition: sounds.c:64
static VOID FreeLabelMap(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:149
#define CBN_SELENDOK
Definition: winuser.h:1971
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4677
static PVOID ptr
Definition: dispmode.c:27
#define CB_ADDSTRING
Definition: winuser.h:1926
HTREEITEM hItem
Definition: treelist.h:37
LONG_PTR LPARAM
Definition: windef.h:208
LPTSTR szFilter
Definition: mplay32.c:30
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
#define CB_ERR
Definition: winuser.h:2425
#define WM_DESTROY
Definition: winuser.h:1599
TVITEMW itemNew
Definition: commctrl.h:3638
#define IDC_SCHEME_LIST
Definition: resource.h:39
#define IDI_SOUND_SECTION
Definition: resource.h:10
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:48
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ASSERT(a)
Definition: mode.c:44
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:54
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define _countof(array)
Definition: sndvol32.h:68
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define MAX_PATH
Definition: compat.h:34
#define IMAGE_SOUND_NONE
Definition: resource.h:96
DWORD lStructSize
Definition: commdlg.h:329
int WINAPI GetSystemMetrics(_In_ int)
struct _GLOBAL_DATA * PGLOBAL_DATA
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define IMAGE_SOUND_ASSIGNED
Definition: resource.h:95
#define SM_CXSMICON
Definition: winuser.h:1006
UINT NumWavOut
Definition: sounds.c:59
#define IDS_WAVE_FILES_FILTER
Definition: resource.h:85
#define DWLP_USER
Definition: winuser.h:866
#define IDC_SOUND_SCHEME
Definition: resource.h:38
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define CB_SETCURSEL
Definition: winuser.h:1951
struct tagNMTREEVIEWW * LPNMTREEVIEWW
#define WM_COMMAND
Definition: winuser.h:1730
#define wcsrchr
Definition: compat.h:16
static VOID FreeSoundProfiles(HWND hwndDlg)
Definition: sounds.c:498
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:66
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDI_PLAY_ICON
Definition: resource.h:5
#define SND_FILENAME
Definition: mmsystem.h:162
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HWND WINAPI GetParent(_In_ HWND)
static ATOM item
Definition: dde.c:856
LPSTR lpstrFile
Definition: commdlg.h:336
#define ComboBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:69
struct _GLOBAL_DATA GLOBAL_DATA
static VOID FreeSoundFiles(HWND hwndDlg)
Definition: sounds.c:875
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TVIF_IMAGE
Definition: commctrl.h:3267
BOOL LoadEventLabels(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:301
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDC_BROWSE_SOUND
Definition: resource.h:49
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR szValue[MAX_PATH]
Definition: sounds.c:42
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
#define IDC_TEXT_SOUND
Definition: resource.h:47
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define HIWORD(l)
Definition: typedefs.h:247
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define SetWindowLongPtrW
Definition: winuser.h:5336
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define TVIF_PARAM
Definition: commctrl.h:3268
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)
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:735
static VOID FreeAppMap(PGLOBAL_DATA pGlobalData)
Definition: sounds.c:188
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define WM_NOTIFY
Definition: richedit.h:61
DWORD Flags
Definition: commdlg.h:342
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
Definition: playsound.c:531

Referenced by MmSysApplet(), and ShowFullControlPanel().