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