mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
Move the settings read code into a single function which is called before creating the property sheet.
svn path=/trunk/; revision=29112
This commit is contained in:
parent
099d7567cb
commit
dffd76151a
6 changed files with 149 additions and 159 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <commctrl.h>
|
||||
#include <cpl.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include "resource.h"
|
||||
#include "access.h"
|
||||
|
||||
|
@ -27,6 +28,135 @@ APPLET Applets[NUM_APPLETS] =
|
|||
};
|
||||
|
||||
|
||||
static BOOL
|
||||
ReadSettings(PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
DWORD dwDisposition;
|
||||
DWORD dwLength;
|
||||
HKEY hKey;
|
||||
LONG lError;
|
||||
|
||||
/* Get sticky keys information */
|
||||
pGlobalData->stickyKeys.cbSize = sizeof(STICKYKEYS);
|
||||
if (!SystemParametersInfo(SPI_GETSTICKYKEYS,
|
||||
sizeof(STICKYKEYS),
|
||||
&pGlobalData->stickyKeys,
|
||||
0))
|
||||
return FALSE;
|
||||
|
||||
/* Get filter keys information */
|
||||
pGlobalData->filterKeys.cbSize = sizeof(FILTERKEYS);
|
||||
if (!SystemParametersInfo(SPI_GETFILTERKEYS,
|
||||
sizeof(FILTERKEYS),
|
||||
&pGlobalData->filterKeys,
|
||||
0))
|
||||
return FALSE;
|
||||
|
||||
/* Get toggle keys information */
|
||||
pGlobalData->toggleKeys.cbSize = sizeof(TOGGLEKEYS);
|
||||
if (!SystemParametersInfo(SPI_GETTOGGLEKEYS,
|
||||
sizeof(TOGGLEKEYS),
|
||||
&pGlobalData->toggleKeys,
|
||||
0))
|
||||
return FALSE;
|
||||
|
||||
/* Get keyboard preference information */
|
||||
if (!SystemParametersInfo(SPI_GETKEYBOARDPREF,
|
||||
0,
|
||||
&pGlobalData->bKeyboardPref,
|
||||
0))
|
||||
return FALSE;
|
||||
|
||||
/* Get high contrast information */
|
||||
pGlobalData->highContrast.cbSize = sizeof(HIGHCONTRAST);
|
||||
SystemParametersInfo(SPI_GETHIGHCONTRAST,
|
||||
sizeof(HIGHCONTRAST),
|
||||
&pGlobalData->highContrast,
|
||||
0);
|
||||
|
||||
SystemParametersInfo(SPI_GETCARETWIDTH,
|
||||
0,
|
||||
&pGlobalData->uCaretWidth,
|
||||
0);
|
||||
|
||||
pGlobalData->uCaretBlinkTime = GetCaretBlinkTime();
|
||||
|
||||
/* get sound settings */
|
||||
pGlobalData->ssSoundSentry.cbSize = sizeof(SOUNDSENTRY);
|
||||
SystemParametersInfo(SPI_GETSOUNDSENTRY,
|
||||
sizeof(SOUNDSENTRY),
|
||||
&pGlobalData->ssSoundSentry,
|
||||
0);
|
||||
|
||||
SystemParametersInfo(SPI_GETSHOWSOUNDS,
|
||||
0,
|
||||
&pGlobalData->bShowSounds,
|
||||
0);
|
||||
|
||||
/* Get mouse keys information */
|
||||
pGlobalData->mouseKeys.cbSize = sizeof(MOUSEKEYS);
|
||||
SystemParametersInfo(SPI_GETMOUSEKEYS,
|
||||
sizeof(MOUSEKEYS),
|
||||
&pGlobalData->mouseKeys,
|
||||
0);
|
||||
|
||||
/* Get access timeout information */
|
||||
pGlobalData->accessTimeout.cbSize = sizeof(ACCESSTIMEOUT);
|
||||
SystemParametersInfo(SPI_GETACCESSTIMEOUT,
|
||||
sizeof(ACCESSTIMEOUT),
|
||||
&pGlobalData->accessTimeout,
|
||||
0);
|
||||
|
||||
/* Get serial keys information */
|
||||
pGlobalData->serialKeys.cbSize = sizeof(SERIALKEYS);
|
||||
pGlobalData->serialKeys.lpszActivePort = pGlobalData->szActivePort;
|
||||
pGlobalData->serialKeys.lpszPort = pGlobalData->szPort;
|
||||
SystemParametersInfo(SPI_GETSERIALKEYS,
|
||||
sizeof(SERIALKEYS),
|
||||
&pGlobalData->serialKeys,
|
||||
0);
|
||||
|
||||
pGlobalData->bWarningSounds = TRUE;
|
||||
pGlobalData->bSoundOnActivation = TRUE;
|
||||
|
||||
lError = RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||
_T("Control Panel\\Accessibility"),
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_EXECUTE | KEY_QUERY_VALUE,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisposition);
|
||||
if (lError != ERROR_SUCCESS)
|
||||
return TRUE;
|
||||
|
||||
dwLength = sizeof(BOOL);
|
||||
lError = RegQueryValueEx(hKey,
|
||||
_T("Warning Sounds"),
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&pGlobalData->bWarningSounds,
|
||||
&dwLength);
|
||||
if (lError != ERROR_SUCCESS)
|
||||
pGlobalData->bWarningSounds = TRUE;
|
||||
|
||||
dwLength = sizeof(BOOL);
|
||||
lError = RegQueryValueEx(hKey,
|
||||
_T("Sound On Activation"),
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&pGlobalData->bSoundOnActivation,
|
||||
&dwLength);
|
||||
if (lError != ERROR_SUCCESS)
|
||||
pGlobalData->bSoundOnActivation = TRUE;
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
|
@ -57,6 +187,9 @@ SystemApplet(VOID)
|
|||
if (pGlobalData == NULL)
|
||||
return 0;
|
||||
|
||||
if (!ReadSettings(pGlobalData))
|
||||
return 0;
|
||||
|
||||
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE;
|
||||
|
|
|
@ -151,20 +151,6 @@ DisplayPageProc(HWND hwndDlg,
|
|||
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
|
||||
/* Get high contrast information */
|
||||
pGlobalData->highContrast.cbSize = sizeof(HIGHCONTRAST);
|
||||
SystemParametersInfo(SPI_GETHIGHCONTRAST,
|
||||
sizeof(HIGHCONTRAST),
|
||||
&pGlobalData->highContrast,
|
||||
0);
|
||||
|
||||
SystemParametersInfo(SPI_GETCARETWIDTH,
|
||||
0,
|
||||
&pGlobalData->uCaretWidth,
|
||||
0);
|
||||
|
||||
pGlobalData->uCaretBlinkTime = GetCaretBlinkTime();
|
||||
|
||||
pGlobalData->fShowCaret = TRUE;
|
||||
GetWindowRect(GetDlgItem(hwndDlg, IDC_CURSOR_WIDTH_TEXT), &pGlobalData->rcCaret);
|
||||
ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.left);
|
||||
|
|
|
@ -130,70 +130,6 @@ FillResetComboBox(HWND hwnd)
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
ReadGlobalData(PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
DWORD dwDisposition;
|
||||
DWORD dwLength;
|
||||
HKEY hKey;
|
||||
LONG lError;
|
||||
|
||||
/* Get access timeout information */
|
||||
pGlobalData->accessTimeout.cbSize = sizeof(ACCESSTIMEOUT);
|
||||
SystemParametersInfo(SPI_GETACCESSTIMEOUT,
|
||||
sizeof(ACCESSTIMEOUT),
|
||||
&pGlobalData->accessTimeout,
|
||||
0);
|
||||
|
||||
/* Get serial keys information */
|
||||
pGlobalData->serialKeys.cbSize = sizeof(SERIALKEYS);
|
||||
pGlobalData->serialKeys.lpszActivePort = pGlobalData->szActivePort;
|
||||
pGlobalData->serialKeys.lpszPort = pGlobalData->szPort;
|
||||
SystemParametersInfo(SPI_GETSERIALKEYS,
|
||||
sizeof(SERIALKEYS),
|
||||
&pGlobalData->serialKeys,
|
||||
0);
|
||||
|
||||
pGlobalData->bWarningSounds = TRUE;
|
||||
pGlobalData->bSoundOnActivation = TRUE;
|
||||
|
||||
lError = RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||
_T("Control Panel\\Accessibility"),
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_EXECUTE | KEY_QUERY_VALUE,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisposition);
|
||||
if (lError != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
dwLength = sizeof(BOOL);
|
||||
lError = RegQueryValueEx(hKey,
|
||||
_T("Warning Sounds"),
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&pGlobalData->bWarningSounds,
|
||||
&dwLength);
|
||||
if (lError != ERROR_SUCCESS)
|
||||
pGlobalData->bWarningSounds = TRUE;
|
||||
|
||||
dwLength = sizeof(BOOL);
|
||||
lError = RegQueryValueEx(hKey,
|
||||
_T("Sound On Activation"),
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&pGlobalData->bSoundOnActivation,
|
||||
&dwLength);
|
||||
if (lError != ERROR_SUCCESS)
|
||||
pGlobalData->bSoundOnActivation = TRUE;
|
||||
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
WriteGlobalData(PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
|
@ -262,8 +198,6 @@ GeneralPageProc(HWND hwndDlg,
|
|||
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
|
||||
ReadGlobalData(pGlobalData);
|
||||
|
||||
/* Set access timeout info */
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_RESET_BOX,
|
||||
|
|
|
@ -580,66 +580,6 @@ ToggleKeysDlgProc(HWND hwndDlg,
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
OnInitDialog(IN HWND hwndDlg, PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
/* Get sticky keys information */
|
||||
pGlobalData->stickyKeys.cbSize = sizeof(STICKYKEYS);
|
||||
if (!SystemParametersInfo(SPI_GETSTICKYKEYS,
|
||||
sizeof(STICKYKEYS),
|
||||
&pGlobalData->stickyKeys,
|
||||
0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get filter keys information */
|
||||
pGlobalData->filterKeys.cbSize = sizeof(FILTERKEYS);
|
||||
if (!SystemParametersInfo(SPI_GETFILTERKEYS,
|
||||
sizeof(FILTERKEYS),
|
||||
&pGlobalData->filterKeys,
|
||||
0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get toggle keys information */
|
||||
pGlobalData->toggleKeys.cbSize = sizeof(TOGGLEKEYS);
|
||||
if (!SystemParametersInfo(SPI_GETTOGGLEKEYS,
|
||||
sizeof(TOGGLEKEYS),
|
||||
&pGlobalData->toggleKeys,
|
||||
0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get keyboard preference information */
|
||||
if (!SystemParametersInfo(SPI_GETKEYBOARDPREF,
|
||||
0,
|
||||
&pGlobalData->bKeyboardPref,
|
||||
0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_STICKY_BOX,
|
||||
pGlobalData->stickyKeys.dwFlags & SKF_STICKYKEYSON ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_FILTER_BOX,
|
||||
pGlobalData->filterKeys.dwFlags & FKF_FILTERKEYSON ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_TOGGLE_BOX,
|
||||
pGlobalData->toggleKeys.dwFlags & TKF_TOGGLEKEYSON ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_KEYBOARD_EXTRA,
|
||||
pGlobalData->bKeyboardPref ? BST_CHECKED : BST_UNCHECKED);
|
||||
}
|
||||
|
||||
|
||||
/* Property page dialog callback */
|
||||
INT_PTR CALLBACK
|
||||
KeyboardPageProc(HWND hwndDlg,
|
||||
|
@ -660,7 +600,22 @@ KeyboardPageProc(HWND hwndDlg,
|
|||
return FALSE;
|
||||
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
OnInitDialog(hwndDlg, pGlobalData);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_STICKY_BOX,
|
||||
pGlobalData->stickyKeys.dwFlags & SKF_STICKYKEYSON ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_FILTER_BOX,
|
||||
pGlobalData->filterKeys.dwFlags & FKF_FILTERKEYSON ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_TOGGLE_BOX,
|
||||
pGlobalData->toggleKeys.dwFlags & TKF_TOGGLEKEYSON ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_KEYBOARD_EXTRA,
|
||||
pGlobalData->bKeyboardPref ? BST_CHECKED : BST_UNCHECKED);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
|
|
|
@ -166,13 +166,6 @@ MousePageProc(HWND hwndDlg,
|
|||
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
|
||||
/* Get mouse keys information */
|
||||
pGlobalData->mouseKeys.cbSize = sizeof(MOUSEKEYS);
|
||||
SystemParametersInfo(SPI_GETMOUSEKEYS,
|
||||
sizeof(MOUSEKEYS),
|
||||
&pGlobalData->mouseKeys,
|
||||
0);
|
||||
|
||||
/* Set the checkbox */
|
||||
CheckDlgButton(hwndDlg,
|
||||
IDC_MOUSE_BOX,
|
||||
|
|
|
@ -22,17 +22,6 @@ OnInitDialog(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
|
|||
TCHAR szBuffer[256];
|
||||
UINT i;
|
||||
|
||||
pGlobalData->ssSoundSentry.cbSize = sizeof(SOUNDSENTRY);
|
||||
SystemParametersInfo(SPI_GETSOUNDSENTRY,
|
||||
sizeof(SOUNDSENTRY),
|
||||
&pGlobalData->ssSoundSentry,
|
||||
0);
|
||||
|
||||
SystemParametersInfo(SPI_GETSHOWSOUNDS,
|
||||
0,
|
||||
&pGlobalData->bShowSounds,
|
||||
0);
|
||||
|
||||
/* Add strings to the combo-box */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue