[WINHTTP] Sync with Wine Staging 3.9. CORE-14656
[reactos.git] / dll / cpl / access / sound.c
1 /*
2 * PROJECT: ReactOS Accessibility Control Panel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/access/sound.c
5 * PURPOSE: Sound-related accessibility settings
6 * COPYRIGHT: Copyright 2004 Johannes Anderwald (johannes.anderwald@reactos.org)
7 * Copyright 2007 Eric Kohl
8 */
9
10 #include "access.h"
11
12 static VOID
13 OnInitDialog(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
14 {
15 TCHAR szBuffer[256];
16 UINT i;
17
18 /* Add strings to the combo-box */
19 for (i = 0; i < 4; i++)
20 {
21 LoadString(hApplet, IDS_SENTRY_NONE + i, szBuffer, 256);
22 SendDlgItemMessage(hwndDlg, IDC_SENTRY_COMBO, CB_ADDSTRING, 0, (LPARAM)szBuffer);
23 }
24
25 /* Select a combo-box item */
26 SendDlgItemMessage(hwndDlg, IDC_SENTRY_COMBO, CB_SETCURSEL, pGlobalData->ssSoundSentry.iWindowsEffect, 0);
27
28 /* Initialize SoundSentry settings */
29 if (!(pGlobalData->ssSoundSentry.dwFlags & SSF_AVAILABLE))
30 {
31 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_BOX), FALSE);
32 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_TEXT), FALSE);
33 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_COMBO), FALSE);
34 }
35 else
36 {
37 if (pGlobalData->ssSoundSentry.dwFlags & SSF_SOUNDSENTRYON)
38 {
39 CheckDlgButton(hwndDlg, IDC_SENTRY_BOX, BST_CHECKED);
40 }
41 else
42 {
43 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_TEXT), FALSE);
44 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_COMBO), FALSE);
45 }
46 }
47
48 /* Initialize ShowSounds settings */
49 if (pGlobalData->bShowSounds)
50 CheckDlgButton(hwndDlg, IDC_SSHOW_BOX, BST_CHECKED);
51 }
52
53
54 /* Property page dialog callback */
55 INT_PTR CALLBACK
56 SoundPageProc(HWND hwndDlg,
57 UINT uMsg,
58 WPARAM wParam,
59 LPARAM lParam)
60 {
61 PGLOBAL_DATA pGlobalData;
62
63 pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
64
65 switch (uMsg)
66 {
67 case WM_INITDIALOG:
68 pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
69
70 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
71
72 OnInitDialog(hwndDlg, pGlobalData);
73 break;
74
75 case WM_COMMAND:
76 switch (LOWORD(wParam))
77 {
78 case IDC_SENTRY_BOX:
79 pGlobalData->ssSoundSentry.dwFlags ^= SSF_SOUNDSENTRYON;
80 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_TEXT), (pGlobalData->ssSoundSentry.dwFlags & SSF_SOUNDSENTRYON)?TRUE:FALSE);
81 EnableWindow(GetDlgItem(hwndDlg, IDC_SENTRY_COMBO), (pGlobalData->ssSoundSentry.dwFlags & SSF_SOUNDSENTRYON)?TRUE:FALSE);
82 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
83 break;
84
85 case IDC_SENTRY_COMBO:
86 if (HIWORD(wParam) == CBN_SELENDOK)
87 {
88 pGlobalData->ssSoundSentry.iWindowsEffect =
89 (DWORD)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
90 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
91 }
92 break;
93
94 case IDC_SSHOW_BOX:
95 pGlobalData->bShowSounds = !pGlobalData->bShowSounds;
96 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
97 break;
98
99 default:
100 break;
101 }
102 break;
103
104 case WM_NOTIFY:
105 switch (((LPNMHDR)lParam)->code)
106 {
107 case PSN_APPLY:
108 SystemParametersInfo(SPI_SETSOUNDSENTRY,
109 sizeof(SOUNDSENTRY),
110 &pGlobalData->ssSoundSentry,
111 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
112 SystemParametersInfo(SPI_SETSHOWSOUNDS,
113 pGlobalData->bShowSounds,
114 0,
115 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
116 return TRUE;
117
118 default:
119 break;
120 }
121 break;
122 }
123
124 return FALSE;
125 }