2 * PROJECT: ReactOS On-Screen Keyboard
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Configuration settings of the application
5 * COPYRIGHT: Copyright 2018-2019 Bișoc George (fraizeraust99 at gmail dot com)
8 /* INCLUDES *******************************************************************/
12 /* FUNCTIONS *******************************************************************/
14 BOOL
LoadDataFromRegistry(VOID
)
19 DWORD cbData
= sizeof(DWORD
);
21 /* Initialize the registry application settings */
22 Globals
.bShowWarning
= TRUE
;
23 Globals
.bIsEnhancedKeyboard
= TRUE
;
24 Globals
.bSoundClick
= FALSE
;
25 Globals
.bAlwaysOnTop
= TRUE
;
27 /* Set the coordinate values to default */
28 Globals
.PosX
= CW_USEDEFAULT
;
29 Globals
.PosY
= CW_USEDEFAULT
;
31 /* Open the key, so that we can query it */
32 lResult
= RegOpenKeyExW(HKEY_CURRENT_USER
,
33 L
"Software\\Microsoft\\Osk",
38 if (lResult
!= ERROR_SUCCESS
)
40 /* Bail out and return FALSE if we fail */
45 lResult
= RegQueryValueExW(hKey
,
52 if (lResult
!= ERROR_SUCCESS
)
54 /* Bail out and return FALSE if we fail */
59 /* Load the data value (it can be either FALSE or TRUE depending on the data itself) */
60 Globals
.bShowWarning
= (dwValue
!= 0);
63 lResult
= RegQueryValueExW(hKey
,
64 L
"IsEnhancedKeyboard",
70 if (lResult
!= ERROR_SUCCESS
)
72 /* Bail out and return FALSE if we fail */
77 /* Load the dialog layout value */
78 Globals
.bIsEnhancedKeyboard
= (dwValue
!= 0);
81 lResult
= RegQueryValueExW(hKey
,
88 if (lResult
!= ERROR_SUCCESS
)
90 /* Bail out and return FALSE if we fail */
95 /* Load the sound on click value event */
96 Globals
.bSoundClick
= (dwValue
!= 0);
99 lResult
= RegQueryValueExW(hKey
,
106 if (lResult
!= ERROR_SUCCESS
)
108 /* Bail out and return FALSE if we fail */
113 /* Load the X value data of the dialog's coordinate */
114 Globals
.PosX
= dwValue
;
116 lResult
= RegQueryValueExW(hKey
,
123 if (lResult
!= ERROR_SUCCESS
)
125 /* Bail out and return FALSE if we fail */
130 /* Load the Y value data of the dialog's coordinate */
131 Globals
.PosY
= dwValue
;
133 lResult
= RegQueryValueExW(hKey
,
140 if (lResult
!= ERROR_SUCCESS
)
142 /* Bail out and return FALSE if we fail */
147 /* Load the window state value data */
148 Globals
.bAlwaysOnTop
= (dwValue
!= 0);
150 /* If we're here then we succeed, close the key and return TRUE */
155 BOOL
SaveDataToRegistry(VOID
)
162 /* Set the structure length and retrieve the dialog's placement */
163 wp
.length
= sizeof(WINDOWPLACEMENT
);
164 GetWindowPlacement(Globals
.hMainWnd
, &wp
);
166 /* If no key has been made, create one */
167 lResult
= RegCreateKeyExW(HKEY_CURRENT_USER
,
168 L
"Software\\Microsoft\\Osk",
177 if (lResult
!= ERROR_SUCCESS
)
179 /* Bail out and return FALSE if we fail */
183 /* The data value of the subkey will be appended to the warning dialog switch */
184 dwValue
= Globals
.bShowWarning
;
186 /* Welcome warning box value key */
187 lResult
= RegSetValueExW(hKey
,
194 if (lResult
!= ERROR_SUCCESS
)
196 /* Bail out and return FALSE if we fail */
201 /* The value will be appended to the layout dialog */
202 dwValue
= Globals
.bIsEnhancedKeyboard
;
204 /* Keyboard dialog switcher */
205 lResult
= RegSetValueExW(hKey
,
206 L
"IsEnhancedKeyboard",
212 if (lResult
!= ERROR_SUCCESS
)
214 /* Bail out and return FALSE if we fail */
219 /* The value will be appended to the sound on click event */
220 dwValue
= Globals
.bSoundClick
;
222 /* "Sound on Click" switcher value key */
223 lResult
= RegSetValueExW(hKey
,
230 if (lResult
!= ERROR_SUCCESS
)
232 /* Bail out and return FALSE if we fail */
237 /* The value will be appended to the X coordination dialog's placement */
238 dwValue
= wp
.rcNormalPosition
.left
;
240 /* Position X coordination of dialog's placement value key */
241 lResult
= RegSetValueExW(hKey
,
248 if (lResult
!= ERROR_SUCCESS
)
250 /* Bail out and return FALSE if we fail */
255 /* The value will be appended to the Y coordination dialog's placement */
256 dwValue
= wp
.rcNormalPosition
.top
;
258 /* Position Y coordination of dialog's placement value key */
259 lResult
= RegSetValueExW(hKey
,
266 if (lResult
!= ERROR_SUCCESS
)
268 /* Bail out and return FALSE if we fail */
273 /* Window top state value */
274 dwValue
= Globals
.bAlwaysOnTop
;
276 /* "Always on Top" state value key */
277 lResult
= RegSetValueExW(hKey
,
284 if (lResult
!= ERROR_SUCCESS
)
286 /* Bail out and return FALSE if we fail */
291 /* If we're here then we succeed, close the key and return TRUE */