ReactOS 0.4.15-dev-7961-gdcf9eb0
SystemParametersInfo.c File Reference
#include "precomp.h"
Include dependency graph for SystemParametersInfo.c:

Go to the source code of this file.

Functions

static int get_iwnd (HWND hWnd)
 
LRESULT CALLBACK SysParamsTestProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static void FlushMessages ()
 
static void Test_NonClientMetrics ()
 
static void Test_MouseSpeed ()
 
static void Test_GradientCaptions (void)
 
 START_TEST (SystemParametersInfo)
 

Variables

static HWND hWnd1
 
static HWND hWnd2
 
static BOOL g_bReadyForDisplayChange = FALSE
 
static HANDLE g_hSemDisplayChange
 
static MSG_ENTRY NcMetricsChange_chain []
 
static MSG_ENTRY NcMetricsChange1_chain []
 
static MSG_ENTRY CaptionHeight_chain []
 

Function Documentation

◆ FlushMessages()

static void FlushMessages ( )
static

Definition at line 56 of file SystemParametersInfo.c.

57{
58 MSG msg;
59
60 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
61 {
62 int iwnd = get_iwnd(msg.hwnd);
63 if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
64 RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
66 }
67}
static int get_iwnd(HWND hWnd)
#define msg(x)
Definition: auth_time.c:54
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
@ POST
Definition: msgtrace.h:7
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define PM_REMOVE
Definition: winuser.h:1196
#define PeekMessage
Definition: winuser.h:5830
#define WM_USER
Definition: winuser.h:1895

Referenced by Test_NonClientMetrics().

◆ get_iwnd()

static int get_iwnd ( HWND  hWnd)
static

Definition at line 16 of file SystemParametersInfo.c.

17{
18 if(hWnd == hWnd1) return 1;
19 else if(hWnd == hWnd2) return 2;
20 else return 0;
21}
static HWND hWnd1
static HWND hWnd2
HWND hWnd
Definition: settings.c:17

Referenced by FlushMessages(), and SysParamsTestProc().

◆ START_TEST()

START_TEST ( SystemParametersInfo  )

Definition at line 271 of file SystemParametersInfo.c.

272{
273 RegisterSimpleClass(SysParamsTestProc, L"sysparamstest");
274 hWnd1 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
275 20, 20, 300, 300, NULL, NULL, 0, NULL);
276
277 hWnd2 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
278 200, 200, 300, 300, NULL, NULL, 0, NULL);
279
283
286 UnregisterClassW(L"sysparamstest", 0);
287}
static void Test_MouseSpeed()
LRESULT CALLBACK SysParamsTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static void Test_GradientCaptions(void)
static void Test_NonClientMetrics()
#define NULL
Definition: types.h:112
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ SysParamsTestProc()

LRESULT CALLBACK SysParamsTestProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 23 of file SystemParametersInfo.c.

24{
25 int iwnd = get_iwnd(hWnd);
26
27 if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
29
30 switch(message)
31 {
32 case WM_GETICON :
33 case WM_SETICON:
34 break;
37 {
38 WINDOWPOS* pwp = (WINDOWPOS*)lParam;
39 ok(wParam==0,"expected wParam=0\n");
41 break;
42 }
43 case WM_DISPLAYCHANGE:
45 {
48 }
49 break;
50 default:
51 RECORD_MESSAGE(iwnd, message, SENT, 0,0);
52 }
54}
static HANDLE g_hSemDisplayChange
static BOOL g_bReadyForDisplayChange
#define ok(value,...)
Definition: atltest.h:57
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define FALSE
Definition: types.h:117
@ SENT
Definition: msgtrace.h:6
#define DefWindowProc
Definition: ros2win.h:31
UINT flags
Definition: winuser.h:3594
HWND hwndInsertAfter
Definition: winuser.h:3589
Definition: tftpd.h:60
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1661
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1662

Referenced by START_TEST().

◆ Test_GradientCaptions()

static void Test_GradientCaptions ( void  )
static

Definition at line 184 of file SystemParametersInfo.c.

185{
186 BOOL ret;
187 LONG lResult;
188 DWORD dwResult;
189 BOOL bGradientCaptions, bModeFound;
190 DEVMODEW OldDevMode, NewDevMode;
191 INT iMode;
192
193 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
194 ok(ret, "SystemParametersInfo failed\n");
195 if (bGradientCaptions == FALSE)
196 {
197 skip("GRADIENTCAPTIONS value has changed from its original state\n");
198 return;
199 }
200
201 /* Try to find a graphics mode with 16 or 256 colors */
202 iMode = 0;
203 bModeFound = FALSE;
204 while (EnumDisplaySettingsW(NULL, iMode, &NewDevMode))
205 {
206 if ((NewDevMode.dmBitsPerPel == 4) ||
207 (NewDevMode.dmBitsPerPel == 8))
208 {
209 bModeFound = TRUE;
210 break;
211 }
212
213 ++iMode;
214 }
215 if (!bModeFound)
216 {
217 skip("4bpp/8bpp graphics mode is not supported\n");
218 return;
219 }
220
221 /* Save the current graphics mode */
223 ok(ret, "EnumDisplaySettingsW failed\n");
224
226
227 /* Switch to the new graphics mode */
229 lResult = ChangeDisplaySettingsExW(NULL, &NewDevMode, NULL, 0, NULL);
230 if (lResult == DISP_CHANGE_SUCCESSFUL)
231 {
232 dwResult = WaitForSingleObject(g_hSemDisplayChange, 10000);
233 ok(dwResult == WAIT_OBJECT_0, "Waiting for the WM_DISPLAYCHANGE message timed out\n");
234 }
236 ok(lResult == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW returned %ld\n", lResult);
237
238 /* SPI_GETGRADIENTCAPTIONS will now always return FALSE */
239 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
240 ok(ret, "SystemParametersInfo failed\n");
241 ok(bGradientCaptions == FALSE, "SPI_GETGRADIENTCAPTIONS got unexpected value (%d instead of 0)\n", bGradientCaptions);
242
243 /* Enable gradient captions */
244 bGradientCaptions = TRUE;
245 SystemParametersInfo(SPI_SETGRADIENTCAPTIONS, 0, UlongToPtr(bGradientCaptions), 0);
246
247 /* Still FALSE */
248 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
249 ok(ret, "SystemParametersInfo failed\n");
250 ok(bGradientCaptions == FALSE, "SPI_GETGRADIENTCAPTIONS got unexpected value (%d instead of 0)\n", bGradientCaptions);
251
252 /* Restore the previous graphics mode */
254 lResult = ChangeDisplaySettingsExW(NULL, &OldDevMode, NULL, 0, NULL);
255 if (lResult == DISP_CHANGE_SUCCESSFUL)
256 {
257 dwResult = WaitForSingleObject(g_hSemDisplayChange, 10000);
258 ok(dwResult == WAIT_OBJECT_0, "Waiting for the WM_DISPLAYCHANGE message timed out\n");
259 }
261 ok(lResult == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW returned %ld\n", lResult);
262
263 /* The original value should be restored */
264 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
265 ok(ret, "SystemParametersInfo failed\n");
266 ok(bGradientCaptions == TRUE, "SPI_GETGRADIENTCAPTIONS got unexpected value (%d instead of 1)\n", bGradientCaptions);
267
269}
#define skip(...)
Definition: atltest.h:64
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
#define UlongToPtr(u)
Definition: config.h:106
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
long LONG
Definition: pedump.c:60
DWORD dmBitsPerPel
Definition: wingdi.h:1647
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
int32_t INT
Definition: typedefs.h:58
int ret
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define WAIT_OBJECT_0
Definition: winbase.h:406
_In_ ULONG iMode
Definition: winddi.h:3520
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
#define SystemParametersInfo
Definition: winuser.h:5858

Referenced by START_TEST().

◆ Test_MouseSpeed()

static void Test_MouseSpeed ( )
static

Definition at line 143 of file SystemParametersInfo.c.

144{
145 ULONG ulMouseSpeed, temp;
146 BOOL ret;
147
148 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &ulMouseSpeed, 0);
149 ok(ret, "SystemParametersInfo failed\n");
150 ok(ulMouseSpeed >= 1 && ulMouseSpeed <=20, "Wrong mouse speed (%d)\n", (int)ulMouseSpeed);
151
152 temp = 1;
154 ok(ret, "SystemParametersInfo failed\n");
155 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
156 ok(ret, "SystemParametersInfo failed\n");
157 ok(temp == 1, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 1)\n", (int)temp);
158
159 temp = 20;
161 ok(ret, "SystemParametersInfo failed\n");
162 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
163 ok(ret, "SystemParametersInfo failed\n");
164 ok(temp == 20, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 20)\n", (int)temp);
165
166 temp = 21;
168 ok(!ret, "expected SystemParametersInfo to fail\n");
169 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
170 ok(ret, "SystemParametersInfo failed\n");
171 ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
172
173 temp = 0;
175 ok(!ret, "expected SystemParametersInfo to fail\n");
176 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
177 ok(ret, "SystemParametersInfo failed\n");
178 ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
179
180 ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, UlongToPtr(ulMouseSpeed), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
181 ok(ret, "SystemParametersInfo failed\n");
182}
static calc_node_t temp
Definition: rpn_ieee.c:38
uint32_t ULONG
Definition: typedefs.h:59
#define SPIF_SENDCHANGE
Definition: winuser.h:1572
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1571

Referenced by START_TEST().

◆ Test_NonClientMetrics()

static void Test_NonClientMetrics ( )
static

Definition at line 106 of file SystemParametersInfo.c.

107{
108 NONCLIENTMETRICS NonClientMetrics;
109
110 /* WARNING: this test requires themes and dwm to be disabled */
111
112 SetCursorPos(0,0);
113
114 /* Retrieve th non client metrics */
115 NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
116 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
119
120 /* Set the non client metric without making any change */
121 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
124
125 /* Set the same metrics again with the SPIF_SENDCHANGE param */
126 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
129
130 /* Slightly change the caption height */
131 NonClientMetrics.iCaptionHeight += 1;
132 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
135
136 /* Restore the original caption height */
137 NonClientMetrics.iCaptionHeight -= 1;
138 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
141}
static void FlushMessages()
static MSG_ENTRY NcMetricsChange1_chain[]
static MSG_ENTRY CaptionHeight_chain[]
static MSG_ENTRY NcMetricsChange_chain[]
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2662

Referenced by START_TEST().

Variable Documentation

◆ CaptionHeight_chain

MSG_ENTRY CaptionHeight_chain[]
static

◆ g_bReadyForDisplayChange

BOOL g_bReadyForDisplayChange = FALSE
static

Definition at line 12 of file SystemParametersInfo.c.

Referenced by SysParamsTestProc(), and Test_GradientCaptions().

◆ g_hSemDisplayChange

HANDLE g_hSemDisplayChange
static

Definition at line 13 of file SystemParametersInfo.c.

Referenced by SysParamsTestProc(), and Test_GradientCaptions().

◆ hWnd1

HWND hWnd1
static

Definition at line 10 of file SystemParametersInfo.c.

Referenced by get_iwnd(), and START_TEST().

◆ hWnd2

HWND hWnd2
static

Definition at line 10 of file SystemParametersInfo.c.

Referenced by get_iwnd(), and START_TEST().

◆ NcMetricsChange1_chain

◆ NcMetricsChange_chain