ReactOS 0.4.16-dev-136-g52192f1
RegisterHotKey.c File Reference
#include "precomp.h"
Include dependency graph for RegisterHotKey.c:

Go to the source code of this file.

Macros

#define msg_hotkey(msg, id, mod, vk)
 
#define expect_hotkey(id, mod, vk)
 
#define msg_no_hotkey(msg)
 
#define expect_no_hotkey()
 

Functions

 START_TEST (RegisterHotKey)
 

Macro Definition Documentation

◆ expect_hotkey

#define expect_hotkey (   id,
  mod,
  vk 
)
Value:
do \
{ \
MSG msg; \
int hotkey_count = 0; \
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) \
{ \
msg_hotkey(&msg, id, mod, vk); \
if (msg.message == WM_HOTKEY) hotkey_count++; \
DispatchMessageW(&msg); \
} \
ok(hotkey_count == 1, "Received %d WM_HOTKEY messages, expected 1\n", hotkey_count); \
} while (0)
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
#define msg(x)
Definition: auth_time.c:54
WORD vk
Definition: input.c:77
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define PM_REMOVE
Definition: winuser.h:1199
#define PeekMessage
Definition: winuser.h:5842
#define WM_HOTKEY
Definition: winuser.h:1882

Definition at line 18 of file RegisterHotKey.c.

◆ expect_no_hotkey

#define expect_no_hotkey ( )
Value:
do \
{ \
MSG msg; \
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) \
{ \
msg_no_hotkey(&msg); \
DispatchMessageW(&msg); \
} \
} while (0)

Definition at line 41 of file RegisterHotKey.c.

◆ msg_hotkey

#define msg_hotkey (   msg,
  id,
  mod,
  vk 
)
Value:
do \
{ \
ok((msg)->message == WM_HOTKEY, "Unexpected message %u\n", (msg)->message); \
ok((msg)->hwnd == NULL, "hwnd = %p\n", (msg)->hwnd); \
ok((msg)->wParam == (id), "wParam = 0x%Ix\n", (msg)->wParam); \
ok((msg)->lParam == MAKELONG(mod, vk), \
"wParam = 0x%Ix, expected 0x%lx\n", (msg)->lParam, MAKELONG(mod, vk)); \
} while (0)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
Definition: tftpd.h:60
#define MAKELONG(a, b)
Definition: typedefs.h:249
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Definition at line 10 of file RegisterHotKey.c.

◆ msg_no_hotkey

#define msg_no_hotkey (   msg)
Value:
do \
{ \
if ((msg)->message == WM_HOTKEY) \
ok((msg)->message != WM_HOTKEY, \
"Got WM_HOTKEY with hwnd=%p, wParam=0x%Ix, lParam=0x%Ix\n", \
(msg)->hwnd, (msg)->wParam, (msg)->lParam); \
else \
ok(0, \
"Unexpected message %u posted to thread with hwnd=%p, wParam=0x%Ix, lParam=0x%Ix\n", \
(msg)->message, (msg)->hwnd, (msg)->wParam, (msg)->lParam); \
} while (0)

Definition at line 30 of file RegisterHotKey.c.

Function Documentation

◆ START_TEST()

START_TEST ( RegisterHotKey  )

Definition at line 51 of file RegisterHotKey.c.

52{
53 SetCursorPos(0, 0);
54
59
61
62 trace("Ctrl only\n");
63 keybd_event(VK_CONTROL, 0, 0, 0);
67
68 trace("Ctrl+U\n");
69 keybd_event(VK_CONTROL, 0, 0, 0);
71 keybd_event('U', 0, 0, 0);
73 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
77
78 trace("Ctrl+U (with Ctrl up first)\n");
79 keybd_event(VK_CONTROL, 0, 0, 0);
81 keybd_event('U', 0, 0, 0);
85 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
87
88 trace("Ctrl+U (with U down first and Ctrl up first)\n");
89 keybd_event('U', 0, 0, 0);
91 keybd_event(VK_CONTROL, 0, 0, 0);
95 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
97
98 trace("Ctrl+U (with U down first and U up first)\n");
99 keybd_event('U', 0, 0, 0);
101 keybd_event(VK_CONTROL, 0, 0, 0);
103 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
107
108 trace("Ctrl+Alt\n");
109 keybd_event(VK_CONTROL, 0, 0, 0);
111 keybd_event(VK_MENU, 0, 0, 0);
117
118 trace("Ctrl+Alt (with Ctrl up first)\n");
119 keybd_event(VK_CONTROL, 0, 0, 0);
121 keybd_event(VK_MENU, 0, 0, 0);
127
128 trace("Alt+Ctrl\n");
129 keybd_event(VK_MENU, 0, 0, 0);
131 keybd_event(VK_CONTROL, 0, 0, 0);
137
138 trace("Alt+Ctrl (with Alt up first)\n");
139 keybd_event(VK_MENU, 0, 0, 0);
141 keybd_event(VK_CONTROL, 0, 0, 0);
147
148 trace("Alt+U\n");
149 keybd_event(VK_MENU, 0, 0, 0);
151 keybd_event('U', 0, 0, 0);
153 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
157
158 trace("Ctrl+Alt+U\n");
159 keybd_event(VK_CONTROL, 0, 0, 0);
161 keybd_event(VK_MENU, 0, 0, 0);
163 keybd_event('U', 0, 0, 0);
165 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
171
172 trace("Alt+Ctrl+U\n");
173 keybd_event(VK_MENU, 0, 0, 0);
175 keybd_event(VK_CONTROL, 0, 0, 0);
177 keybd_event('U', 0, 0, 0);
179 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
185
186 trace("Ctrl+U+Alt\n");
187 keybd_event(VK_CONTROL, 0, 0, 0);
189 keybd_event('U', 0, 0, 0);
190 expect_hotkey(2, MOD_CONTROL, 'U');
191 keybd_event(VK_MENU, 0, 0, 0);
195 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
199
200 trace("Alt+U+Ctrl\n");
201 keybd_event(VK_MENU, 0, 0, 0);
203 keybd_event('U', 0, 0, 0);
205 keybd_event(VK_CONTROL, 0, 0, 0);
209 keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
213
214 /* The remaining combinations are an exercise left to the reader */
215
220
222}
#define expect_hotkey(id, mod, vk)
#define expect_no_hotkey()
#define trace
Definition: atltest.h:70
#define MOD_ALT
Definition: imm.h:184
#define MOD_CONTROL
Definition: imm.h:185
BOOL WINAPI UnregisterHotKey(_In_opt_ HWND, _In_ int)
#define VK_CONTROL
Definition: winuser.h:2206
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2714
BOOL WINAPI RegisterHotKey(_In_opt_ HWND, _In_ int, _In_ UINT, _In_ UINT)
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
#define KEYEVENTF_KEYUP
Definition: winuser.h:1105
#define VK_MENU
Definition: winuser.h:2207