ReactOS  0.4.15-dev-1374-g8d3e80e
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 ()
 
 START_TEST (SystemParametersInfo)
 

Variables

HWND hWnd1
 
HWND hWnd2
 
MSG_ENTRY NcMetricsChange_chain []
 
MSG_ENTRY NcMetricsChange1_chain []
 
MSG_ENTRY CaptionHeight_chain []
 

Function Documentation

◆ FlushMessages()

static void FlushMessages ( )
static

Definition at line 46 of file SystemParametersInfo.c.

47 {
48  MSG msg;
49 
50  while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
51  {
52  int iwnd = get_iwnd(msg.hwnd);
53  if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
54  RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
56  }
57 }
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 13 of file SystemParametersInfo.c.

14 {
15  if(hWnd == hWnd1) return 1;
16  else if(hWnd == hWnd2) return 2;
17  else return 0;
18 }
HWND hWnd1
HWND hWnd
Definition: settings.c:17
HWND hWnd2

Referenced by FlushMessages(), and SysParamsTestProc().

◆ START_TEST()

START_TEST ( SystemParametersInfo  )

Definition at line 174 of file SystemParametersInfo.c.

175 {
176  RegisterSimpleClass(SysParamsTestProc, L"sysparamstest");
177  hWnd1 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
178  20, 20, 300, 300, NULL, NULL, 0, NULL);
179 
180  hWnd2 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
181  200, 200, 300, 300, NULL, NULL, 0, NULL);
182 
184  Test_MouseSpeed();
185 
188  UnregisterClassW(L"sysparamstest", 0);
189 }
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 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 20 of file SystemParametersInfo.c.

21 {
22  int iwnd = get_iwnd(hWnd);
23 
24  if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
26 
27  switch(message)
28  {
29  case WM_GETICON :
30  case WM_SETICON:
31  break;
34  {
35  WINDOWPOS* pwp = (WINDOWPOS*)lParam;
36  ok(wParam==0,"expected wParam=0\n");
38  break;
39  }
40  default:
41  RECORD_MESSAGE(iwnd, message, SENT, 0,0);
42  }
44 }
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
UINT flags
Definition: winuser.h:3569
#define DefWindowProc
Definition: ros2win.h:31
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
#define WM_USER
Definition: winuser.h:1877
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define ok(value,...)
Definition: atltest.h:57
static int get_iwnd(HWND hWnd)
Definition: msgtrace.h:6
#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_MouseSpeed()

static void Test_MouseSpeed ( )
static

Definition at line 133 of file SystemParametersInfo.c.

134 {
135  ULONG ulMouseSpeed, temp;
136  BOOL ret;
137 
138  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &ulMouseSpeed, 0);
139  ok(ret, "SystemParametersInfo failed\n");
140  ok(ulMouseSpeed >= 1 && ulMouseSpeed <=20, "Wrong mouse speed (%d)\n", (int)ulMouseSpeed);
141 
142  temp = 1;
144  ok(ret, "SystemParametersInfo failed\n");
145  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
146  ok(ret, "SystemParametersInfo failed\n");
147  ok(temp == 1, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 1)\n", (int)temp);
148 
149  temp = 20;
151  ok(ret, "SystemParametersInfo failed\n");
152  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
153  ok(ret, "SystemParametersInfo failed\n");
154  ok(temp == 20, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 20)\n", (int)temp);
155 
156  temp = 21;
158  ok(!ret, "expected SystemParametersInfo to fail\n");
159  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
160  ok(ret, "SystemParametersInfo failed\n");
161  ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
162 
163  temp = 0;
165  ok(!ret, "expected SystemParametersInfo to fail\n");
166  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
167  ok(ret, "SystemParametersInfo failed\n");
168  ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
169 
170  ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, UlongToPtr(ulMouseSpeed), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
171  ok(ret, "SystemParametersInfo failed\n");
172 }
#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 96 of file SystemParametersInfo.c.

97 {
98  NONCLIENTMETRICS NonClientMetrics;
99 
100  /* WARNING: this test requires themes and dwm to be disabled */
101 
102  SetCursorPos(0,0);
103 
104  /* Retrieve th non client metrics */
105  NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
106  SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
107  FlushMessages();
109 
110  /* Set the non client metric without making any change */
111  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
112  FlushMessages();
114 
115  /* Set the same metrics again with the SPIF_SENDCHANGE param */
116  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
117  FlushMessages();
119 
120  /* Slightly change the caption height */
121  NonClientMetrics.iCaptionHeight += 1;
122  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
123  FlushMessages();
125 
126  /* Restore the original caption height */
127  NonClientMetrics.iCaptionHeight -= 1;
128  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
129  FlushMessages();
131 }
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 83 of file SystemParametersInfo.c.

Referenced by Test_NonClientMetrics().

◆ 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 70 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 59 of file SystemParametersInfo.c.

Referenced by Test_NonClientMetrics().