-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyChecker.cpp
More file actions
70 lines (63 loc) · 1.58 KB
/
KeyChecker.cpp
File metadata and controls
70 lines (63 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// KeyChecker.cpp
// Author: katahiromz
// License: MIT
#include <windows.h>
#include "winxx.h"
#define MSGDUMP_PRINTF printf
#include "msgdump.h"
#include "vk.h"
BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
return TRUE;
}
void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch (id)
{
case IDOK:
case IDCANCEL:
EndDialog(hwnd, id);
break;
}
}
void OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
{
if (fDown)
printf("WM_KEYDOWN vk: %s (0x%X)\n", get_vk_name(vk), vk);
}
void OnSysKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
{
if (fDown)
printf("WM_SYSKEYDOWN vk: %s (0x%X)\n", get_vk_name(vk), vk);
}
void OnChar(HWND hwnd, TCHAR ch, int cRepeat)
{
if (cRepeat == 1)
printf("WM_CHAR ch: %c (0x%X)\n", ch, ch);
}
INT_PTR CALLBACK
DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MD_msgresult(hwnd, uMsg, wParam, lParam, 0);
switch (uMsg)
{
HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitDialog);
HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
HANDLE_MSG(hwnd, WM_CHAR, OnChar);
HANDLE_MSG(hwnd, WM_KEYDOWN, OnKey);
HANDLE_MSG(hwnd, WM_KEYUP, OnKey);
HANDLE_MSG(hwnd, WM_SYSKEYDOWN, OnSysKey);
HANDLE_MSG(hwnd, WM_SYSKEYUP, OnSysKey);
}
return 0;
}
INT WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
InitCommonControls();
DialogBox(hInstance, MAKEINTRESOURCE(1), NULL, DialogProc);
return 0;
}