Author: ekohl
Date: Thu Sep 20 01:31:49 2007
New Revision: 29112
URL:
http://svn.reactos.org/svn/reactos?rev=29112&view=rev
Log:
Move the settings read code into a single function which is called before creating the
property sheet.
Modified:
trunk/reactos/dll/cpl/access/access.c
trunk/reactos/dll/cpl/access/display.c
trunk/reactos/dll/cpl/access/general.c
trunk/reactos/dll/cpl/access/keyboard.c
trunk/reactos/dll/cpl/access/mouse.c
trunk/reactos/dll/cpl/access/sound.c
Modified: trunk/reactos/dll/cpl/access/access.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/access/access.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/access/access.c (original)
+++ trunk/reactos/dll/cpl/access/access.c Thu Sep 20 01:31:49 2007
@@ -12,6 +12,7 @@
#include <commctrl.h>
#include <cpl.h>
#include <stdlib.h>
+#include <tchar.h>
#include "resource.h"
#include "access.h"
@@ -25,6 +26,135 @@
{
{IDI_CPLACCESS, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
};
+
+
+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
@@ -55,6 +185,9 @@
pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
if (pGlobalData == NULL)
+ return 0;
+
+ if (!ReadSettings(pGlobalData))
return 0;
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
Modified: trunk/reactos/dll/cpl/access/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/access/display.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/access/display.c (original)
+++ trunk/reactos/dll/cpl/access/display.c Thu Sep 20 01:31:49 2007
@@ -150,20 +150,6 @@
return FALSE;
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);
Modified: trunk/reactos/dll/cpl/access/general.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/access/general.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/access/general.c (original)
+++ trunk/reactos/dll/cpl/access/general.c Thu Sep 20 01:31:49 2007
@@ -127,70 +127,6 @@
0,
(LPARAM)szBuffer);
}
-}
-
-
-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);
}
@@ -262,8 +198,6 @@
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
- ReadGlobalData(pGlobalData);
-
/* Set access timeout info */
CheckDlgButton(hwndDlg,
IDC_RESET_BOX,
Modified: trunk/reactos/dll/cpl/access/keyboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/access/keyboard.c?…
==============================================================================
--- trunk/reactos/dll/cpl/access/keyboard.c (original)
+++ trunk/reactos/dll/cpl/access/keyboard.c Thu Sep 20 01:31:49 2007
@@ -580,66 +580,6 @@
}
-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 @@
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:
Modified: trunk/reactos/dll/cpl/access/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/access/mouse.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/access/mouse.c (original)
+++ trunk/reactos/dll/cpl/access/mouse.c Thu Sep 20 01:31:49 2007
@@ -166,13 +166,6 @@
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,
Modified: trunk/reactos/dll/cpl/access/sound.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/access/sound.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/access/sound.c (original)
+++ trunk/reactos/dll/cpl/access/sound.c Thu Sep 20 01:31:49 2007
@@ -21,17 +21,6 @@
{
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++)