ReactOS  0.4.15-dev-2506-g83dbb6b
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

HWND hWnd1
 
HWND hWnd2
 
static BOOL g_bReadyForDisplayChange = FALSE
 
static HANDLE g_hSemDisplayChange
 
MSG_ENTRY NcMetricsChange_chain []
 
MSG_ENTRY NcMetricsChange1_chain []
 
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 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5805
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
Definition: msgtrace.h:7
#define WM_USER
Definition: winuser.h:1877
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
static int get_iwnd(HWND hWnd)
#define msg(x)
Definition: auth_time.c:54
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define PM_REMOVE
Definition: winuser.h:1182

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 }
HWND hWnd1
HWND hWnd
Definition: settings.c:17
HWND hWnd2

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 
281  Test_MouseSpeed();
283 
286  UnregisterClassW(L"sysparamstest", 0);
287 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
HWND hWnd1
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
HWND hWnd2
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
static void Test_MouseSpeed()
static void Test_GradientCaptions(void)
static const WCHAR L[]
Definition: oid.c:1250
static void Test_NonClientMetrics()
LRESULT CALLBACK SysParamsTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
#define NULL
Definition: types.h:112
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637

◆ 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 }
Definition: tftpd.h:59
HWND hWnd
Definition: settings.c:17
HWND hwndInsertAfter
Definition: winuser.h:3564
WPARAM wParam
Definition: combotst.c:138
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
#define FALSE
Definition: types.h:117
UINT flags
Definition: winuser.h:3569
#define DefWindowProc
Definition: ros2win.h:31
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
static BOOL g_bReadyForDisplayChange
#define WM_USER
Definition: winuser.h:1877
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
static HANDLE g_hSemDisplayChange
#define ok(value,...)
Definition: atltest.h:57
static int get_iwnd(HWND hWnd)
Definition: msgtrace.h:6
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
LPARAM lParam
Definition: combotst.c:139

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 CloseHandle
Definition: compat.h:598
_In_ ULONG iMode
Definition: winddi.h:3520
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
#define TRUE
Definition: types.h:120
#define SystemParametersInfo
Definition: winuser.h:5833
DWORD dmBitsPerPel
Definition: wingdi.h:1646
int32_t INT
Definition: typedefs.h:58
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define UlongToPtr(u)
Definition: config.h:106
#define WAIT_OBJECT_0
Definition: winbase.h:403
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL g_bReadyForDisplayChange
int ret
static HANDLE g_hSemDisplayChange
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64

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 }
#define SystemParametersInfo
Definition: winuser.h:5833
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UlongToPtr(u)
Definition: config.h:106
int ret
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
static calc_node_t temp
Definition: rpn_ieee.c:38
#define ok(value,...)
Definition: atltest.h:57
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
unsigned int ULONG
Definition: retypes.h:1

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);
117  FlushMessages();
119 
120  /* Set the non client metric without making any change */
121  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
122  FlushMessages();
124 
125  /* Set the same metrics again with the SPIF_SENDCHANGE param */
126  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
127  FlushMessages();
129 
130  /* Slightly change the caption height */
131  NonClientMetrics.iCaptionHeight += 1;
132  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
133  FlushMessages();
135 
136  /* Restore the original caption height */
137  NonClientMetrics.iCaptionHeight -= 1;
138  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
139  FlushMessages();
141 }
MSG_ENTRY CaptionHeight_chain[]
MSG_ENTRY NcMetricsChange1_chain[]
#define SystemParametersInfo
Definition: winuser.h:5833
static void FlushMessages()
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
MSG_ENTRY NcMetricsChange_chain[]
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20

Referenced by START_TEST().

Variable Documentation

◆ CaptionHeight_chain

MSG_ENTRY CaptionHeight_chain[]
Initial value:

Definition at line 93 of file SystemParametersInfo.c.

Referenced by Test_NonClientMetrics().

◆ 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

Definition at line 10 of file SystemParametersInfo.c.

Referenced by get_iwnd(), and START_TEST().

◆ hWnd2

HWND hWnd2

Definition at line 10 of file SystemParametersInfo.c.

Referenced by get_iwnd(), and START_TEST().

◆ NcMetricsChange1_chain

MSG_ENTRY NcMetricsChange1_chain[]
Initial value:
={
{0,0}}
#define WM_NCCALCSIZE
Definition: winuser.h:1667
#define SWP_NOZORDER
Definition: winuser.h:1232
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
#define SWP_NOSIZE
Definition: winuser.h:1230
#define SWP_NOREDRAW
Definition: winuser.h:1231
Definition: msgtrace.h:6
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
#define SWP_NOCLIENTMOVE
Definition: msg.h:30
#define SWP_NOMOVE
Definition: winuser.h:1229
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
#define WM_GETMINMAXINFO
Definition: winuser.h:1622

Definition at line 80 of file SystemParametersInfo.c.

Referenced by Test_NonClientMetrics().

◆ NcMetricsChange_chain

MSG_ENTRY NcMetricsChange_chain[]
Initial value:
={
{0,0}}
#define WM_NCCALCSIZE
Definition: winuser.h:1667
#define SWP_NOZORDER
Definition: winuser.h:1232
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
#define SWP_NOSIZE
Definition: winuser.h:1230
#define SWP_NOREDRAW
Definition: winuser.h:1231
Definition: msgtrace.h:6
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
#define SWP_NOCLIENTMOVE
Definition: msg.h:30
#define SWP_NOMOVE
Definition: winuser.h:1229
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
#define WM_GETMINMAXINFO
Definition: winuser.h:1622

Definition at line 69 of file SystemParametersInfo.c.

Referenced by Test_NonClientMetrics().