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 *******************************************************************/
13 /* FUNCTIONS *******************************************************************/
15 BOOL
LoadDataFromRegistry()
19 DWORD dwShowWarningData
, dwLayout
, dwSoundOnClick
, dwPositionLeft
, dwPositionTop
;
20 DWORD cbData
= sizeof(DWORD
);
22 /* Set the structure members to TRUE (and the bSoundClick member to FALSE) */
23 Globals
.bShowWarning
= TRUE
;
24 Globals
.bIsEnhancedKeyboard
= TRUE
;
25 Globals
.bSoundClick
= FALSE
;
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
,
49 (BYTE
*)&dwShowWarningData
,
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
= (dwShowWarningData
!= 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
= (dwLayout
!= 0);
81 lResult
= RegQueryValueExW(hKey
,
85 (BYTE
*)&dwSoundOnClick
,
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
= (dwSoundOnClick
!= 0);
99 lResult
= RegQueryValueExW(hKey
,
103 (BYTE
*)&dwPositionLeft
,
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
= dwPositionLeft
;
116 lResult
= RegQueryValueExW(hKey
,
120 (BYTE
*)&dwPositionTop
,
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
= dwPositionTop
;
133 /* If we're here then we succeed, close the key and return TRUE */
138 BOOL
SaveDataToRegistry()
142 DWORD dwShowWarningData
, dwLayout
, dwSoundOnClick
, dwPositionLeft
, dwPositionTop
;
145 /* Set the structure length and retrieve the dialog's placement */
146 wp
.length
= sizeof(WINDOWPLACEMENT
);
147 GetWindowPlacement(Globals
.hMainWnd
, &wp
);
149 /* If no key has been made, create one */
150 lResult
= RegCreateKeyExW(HKEY_CURRENT_USER
,
151 L
"Software\\Microsoft\\Osk",
160 if (lResult
!= ERROR_SUCCESS
)
162 /* Bail out and return FALSE if we fail */
166 /* The data value of the subkey will be appended to the warning dialog switch */
167 dwShowWarningData
= Globals
.bShowWarning
;
169 /* Welcome warning box value key */
170 lResult
= RegSetValueExW(hKey
,
174 (BYTE
*)&dwShowWarningData
,
175 sizeof(dwShowWarningData
));
177 if (lResult
!= ERROR_SUCCESS
)
179 /* Bail out and return FALSE if we fail */
184 /* The value will be appended to the layout dialog */
185 dwLayout
= Globals
.bIsEnhancedKeyboard
;
187 /* Keyboard dialog switcher */
188 lResult
= RegSetValueExW(hKey
,
189 L
"IsEnhancedKeyboard",
195 if (lResult
!= ERROR_SUCCESS
)
197 /* Bail out and return FALSE if we fail */
202 /* The value will be appended to the sound on click event */
203 dwSoundOnClick
= Globals
.bSoundClick
;
205 /* "Sound on Click" switcher value key */
206 lResult
= RegSetValueExW(hKey
,
210 (BYTE
*)&dwSoundOnClick
,
211 sizeof(dwSoundOnClick
));
213 if (lResult
!= ERROR_SUCCESS
)
215 /* Bail out and return FALSE if we fail */
220 /* The value will be appended to the X coordination dialog's placement */
221 dwPositionLeft
= wp
.rcNormalPosition
.left
;
223 /* Position X coordination of dialog's placement value key */
224 lResult
= RegSetValueExW(hKey
,
228 (BYTE
*)&dwPositionLeft
,
229 sizeof(dwPositionLeft
));
231 if (lResult
!= ERROR_SUCCESS
)
233 /* Bail out and return FALSE if we fail */
238 /* The value will be appended to the Y coordination dialog's placement */
239 dwPositionTop
= wp
.rcNormalPosition
.top
;
241 /* Position Y coordination of dialog's placement value key */
242 lResult
= RegSetValueExW(hKey
,
246 (BYTE
*)&dwPositionTop
,
247 sizeof(dwPositionTop
));
249 if (lResult
!= ERROR_SUCCESS
)
251 /* Bail out and return FALSE if we fail */
256 /* If we're here then we succeed, close the key and return TRUE */