ReactOS  0.4.15-dev-1374-g8d3e80e
GetMessageTime.c File Reference
#include "precomp.h"
Include dependency graph for GetMessageTime.c:

Go to the source code of this file.

Macros

#define TIMER_ID   999
 
#define TIMER_INTERVAL   500 /* 500 milliseconds */
 
#define MOUSE_LOCATION_X(x)   ((DWORD)(x) * 0xFFFF / GetSystemMetrics(SM_CXSCREEN))
 
#define MOUSE_LOCATION_Y(y)   ((DWORD)(y) * 0xFFFF / GetSystemMetrics(SM_CYSCREEN))
 
#define WIN_X   50
 
#define WIN_Y   50
 
#define WIN_CX   100
 
#define WIN_CY   100
 

Functions

static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (GetMessageTime)
 

Variables

static INT s_nCount = 0
 
static LONG s_nMsgTime = 0
 

Macro Definition Documentation

◆ MOUSE_LOCATION_X

#define MOUSE_LOCATION_X (   x)    ((DWORD)(x) * 0xFFFF / GetSystemMetrics(SM_CXSCREEN))

Definition at line 12 of file GetMessageTime.c.

◆ MOUSE_LOCATION_Y

#define MOUSE_LOCATION_Y (   y)    ((DWORD)(y) * 0xFFFF / GetSystemMetrics(SM_CYSCREEN))

Definition at line 13 of file GetMessageTime.c.

◆ TIMER_ID

#define TIMER_ID   999

Definition at line 9 of file GetMessageTime.c.

◆ TIMER_INTERVAL

#define TIMER_INTERVAL   500 /* 500 milliseconds */

Definition at line 10 of file GetMessageTime.c.

◆ WIN_CX

#define WIN_CX   100

Definition at line 17 of file GetMessageTime.c.

◆ WIN_CY

#define WIN_CY   100

Definition at line 18 of file GetMessageTime.c.

◆ WIN_X

#define WIN_X   50

Definition at line 15 of file GetMessageTime.c.

◆ WIN_Y

#define WIN_Y   50

Definition at line 16 of file GetMessageTime.c.

Function Documentation

◆ START_TEST()

START_TEST ( GetMessageTime  )

Definition at line 106 of file GetMessageTime.c.

107 {
108  static const WCHAR s_szName[] = L"MessageTimeTestWindow";
109  WNDCLASSW wc;
110  ATOM atom;
111  HWND hwnd;
112  MSG msg;
113  BOOL bRet;
114 
117  0, 0);
118 
119  ZeroMemory(&wc, sizeof(wc));
120  wc.lpfnWndProc = WindowProc;
124  wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
125  wc.lpszClassName = s_szName;
126  atom = RegisterClassW(&wc);
127  ok(atom != 0, "RegisterClassW\n");
128 
133  ok(hwnd != NULL, "CreateWindowW\n");
134 
135  if (hwnd)
136  {
139 
140  while (GetMessageW(&msg, NULL, 0, 0))
141  {
144  }
145  }
146  else
147  {
148  skip("hwnd was NULL.\n");
149  }
150 
152  ok_int(bRet, 1);
153 
154  ok_int(s_nCount, 5);
155  ok(s_nMsgTime != 0, "message time was zero.\n");
156 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1180
#define WIN_Y
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
WORD ATOM
Definition: dimm.idl:113
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
#define ZeroMemory
Definition: winbase.h:1648
#define IDI_APPLICATION
Definition: winuser.h:699
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
static INT s_nCount
#define COLOR_3DFACE
Definition: winuser.h:919
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
unsigned int BOOL
Definition: ntddk_ex.h:94
WNDPROC lpfnWndProc
Definition: winuser.h:3152
#define WIN_X
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
#define ok_int(expression, result)
Definition: atltest.h:134
LPCWSTR lpszClassName
Definition: winuser.h:3160
#define WIN_CY
#define MOUSE_LOCATION_X(x)
#define MOUSE_LOCATION_Y(y)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HICON hIcon
Definition: winuser.h:3156
static const WCHAR L[]
Definition: oid.c:1250
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define LoadCursor
Definition: winuser.h:5787
HCURSOR hCursor
Definition: winuser.h:3157
#define WIN_CX
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1169
HBRUSH hbrBackground
Definition: winuser.h:3158
#define ok(value,...)
Definition: atltest.h:57
static WCHAR s_szName[MAX_PATH]
Definition: find.c:34
#define NULL
Definition: types.h:112
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HINSTANCE hInstance
Definition: winuser.h:3155
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static LONG s_nMsgTime
#define LoadIcon
Definition: winuser.h:5788

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 24 of file GetMessageTime.c.

25 {
26  static BOOL s_bReach_WM_MOUSEMOVE;
27  static BOOL s_bReach_WM_LBUTTONDOWN;
28  static BOOL s_bReach_WM_LBUTTONUP;
29  switch (uMsg)
30  {
31  case WM_CREATE:
32  s_nCount = 0;
35  s_bReach_WM_MOUSEMOVE = FALSE;
36  s_bReach_WM_LBUTTONDOWN = FALSE;
37  s_bReach_WM_LBUTTONUP = FALSE;
38  break;
39  case WM_TIMER:
40  if (s_nCount == 5)
41  {
44  break;
45  }
46  if (s_nCount != 0)
47  {
49  "GetMessageTime() is wrong, compared to previous one\n");
51  "GetMessageTime() is wrong, compared to GetTickCount()\n");
52  }
54  ok(s_nMsgTime != 0, "message time was zero.\n");
55  s_nCount++;
56  if (s_nCount == 5)
57  {
61  0, 0);
62  mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
63  mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
64  mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
65  }
66  break;
67  case WM_MOUSEMOVE:
68  trace("WM_MOUSEMOVE\n");
69  ok_int(s_nCount, 5);
71  "GetMessageTime() is wrong, compared to previous one\n");
73  "GetMessageTime() is wrong, compared to GetTickCount()\n");
74  s_bReach_WM_MOUSEMOVE = TRUE;
75  break;
76  case WM_LBUTTONDOWN:
77  trace("WM_LBUTTONDOWN\n");
78  ok_int(s_nCount, 5);
80  "GetMessageTime() is wrong, compared to previous one\n");
82  "GetMessageTime() is wrong, compared to GetTickCount()\n");
83  s_bReach_WM_LBUTTONDOWN = TRUE;
84  break;
85  case WM_LBUTTONUP:
86  trace("WM_LBUTTONUP\n");
87  ok_int(s_nCount, 5);
89  "GetMessageTime() is wrong, compared to previous one\n");
91  "GetMessageTime() is wrong, compared to GetTickCount()\n");
92  s_bReach_WM_LBUTTONUP = TRUE;
93  break;
94  case WM_DESTROY:
95  ok_int(s_bReach_WM_MOUSEMOVE, TRUE);
96  ok_int(s_bReach_WM_LBUTTONDOWN, TRUE);
97  ok_int(s_bReach_WM_LBUTTONUP, TRUE);
98  PostQuitMessage(0);
99  break;
100  default:
101  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
102  }
103  return 0;
104 }
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1180
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define WIN_Y
UINT uMsg
Definition: menu.cpp:213
#define TRUE
Definition: types.h:120
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
LONG WINAPI GetMessageTime(void)
Definition: message.c:1361
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static INT s_nCount
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WIN_X
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
#define ok_int(expression, result)
Definition: atltest.h:134
#define WIN_CY
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define MOUSE_LOCATION_X(x)
#define trace
Definition: atltest.h:70
#define TIMER_INTERVAL
#define MOUSE_LOCATION_Y(y)
#define WM_TIMER
Definition: winuser.h:1724
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1171
#define WIN_CX
#define TIMER_ID
Definition: GetMessageTime.c:9
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1169
#define ok(value,...)
Definition: atltest.h:57
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define NULL
Definition: types.h:112
#define WM_CREATE
Definition: winuser.h:1590
static LONG s_nMsgTime
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by START_TEST().

Variable Documentation

◆ s_nCount

INT s_nCount = 0
static

Definition at line 20 of file GetMessageTime.c.

Referenced by START_TEST(), and WindowProc().

◆ s_nMsgTime

LONG s_nMsgTime = 0
static

Definition at line 21 of file GetMessageTime.c.

Referenced by START_TEST(), and WindowProc().