-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugHelper.h
290 lines (283 loc) · 12.1 KB
/
DebugHelper.h
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#pragma once
#include "TimestampLogger.h"
#include <map>
class DebugHelper
{
public:
static std::wstring FormatWindowMessage(MSG msg);
static std::wstring FormatWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
DebugHelper() { }
};
const std::map<UINT, std::wstring> kWindowsMessageCodeMap =
{
{ WM_NULL, L"WM_NULL" },
{ WM_CREATE, L"WM_CREATE" },
{ WM_DESTROY, L"WM_DESTROY" },
{ WM_MOVE, L"WM_MOVE" },
{ WM_SIZE, L"WM_SIZE" },
{ WM_ACTIVATE, L"WM_ACTIVATE" },
{ WM_SETFOCUS, L"WM_SETFOCUS" },
{ WM_KILLFOCUS, L"WM_KILLFOCUS" },
{ WM_ENABLE, L"WM_ENABLE" },
{ WM_SETREDRAW, L"WM_SETREDRAW" },
{ WM_SETTEXT, L"WM_SETTEXT" },
{ WM_GETTEXT, L"WM_GETTEXT" },
{ WM_GETTEXTLENGTH, L"WM_GETTEXTLENGTH" },
{ WM_PAINT, L"WM_PAINT" },
{ WM_CLOSE, L"WM_CLOSE" },
{ WM_QUERYENDSESSION, L"WM_QUERYENDSESSION" },
{ WM_QUERYOPEN, L"WM_QUERYOPEN" },
{ WM_ENDSESSION, L"WM_ENDSESSION" },
{ WM_QUIT, L"WM_QUIT" },
{ WM_ERASEBKGND, L"WM_ERASEBKGND" },
{ WM_SYSCOLORCHANGE, L"WM_SYSCOLORCHANGE" },
{ WM_SHOWWINDOW, L"WM_SHOWWINDOW" },
{ WM_WININICHANGE, L"WM_WININICHANGE" },
{ WM_DEVMODECHANGE, L"WM_DEVMODECHANGE" },
{ WM_ACTIVATEAPP, L"WM_ACTIVATEAPP" },
{ WM_FONTCHANGE, L"WM_FONTCHANGE" },
{ WM_TIMECHANGE, L"WM_TIMECHANGE" },
{ WM_CANCELMODE, L"WM_CANCELMODE" },
{ WM_SETCURSOR, L"WM_SETCURSOR" },
{ WM_MOUSEACTIVATE, L"WM_MOUSEACTIVATE" },
{ WM_CHILDACTIVATE, L"WM_CHILDACTIVATE" },
{ WM_QUEUESYNC, L"WM_QUEUESYNC" },
{ WM_GETMINMAXINFO, L"WM_GETMINMAXINFO" },
{ WM_PAINTICON, L"WM_PAINTICON" },
{ WM_ICONERASEBKGND, L"WM_ICONERASEBKGND" },
{ WM_NEXTDLGCTL, L"WM_NEXTDLGCTL" },
{ WM_SPOOLERSTATUS, L"WM_SPOOLERSTATUS" },
{ WM_DRAWITEM, L"WM_DRAWITEM" },
{ WM_MEASUREITEM, L"WM_MEASUREITEM" },
{ WM_DELETEITEM, L"WM_DELETEITEM" },
{ WM_VKEYTOITEM, L"WM_VKEYTOITEM" },
{ WM_CHARTOITEM, L"WM_CHARTOITEM" },
{ WM_SETFONT, L"WM_SETFONT" },
{ WM_GETFONT, L"WM_GETFONT" },
{ WM_SETHOTKEY, L"WM_SETHOTKEY" },
{ WM_GETHOTKEY, L"WM_GETHOTKEY" },
{ WM_QUERYDRAGICON, L"WM_QUERYDRAGICON" },
{ WM_COMPAREITEM, L"WM_COMPAREITEM" },
{ WM_GETOBJECT, L"WM_GETOBJECT" },
{ WM_COMPACTING, L"WM_COMPACTING" },
{ WM_COMMNOTIFY, L"WM_COMMNOTIFY" },
{ WM_WINDOWPOSCHANGING, L"WM_WINDOWPOSCHANGING" },
{ WM_WINDOWPOSCHANGED, L"WM_WINDOWPOSCHANGED" },
{ WM_POWER, L"WM_POWER" },
{ WM_COPYDATA, L"WM_COPYDATA" },
{ WM_CANCELJOURNAL, L"WM_CANCELJOURNAL" },
{ WM_NOTIFY, L"WM_NOTIFY" },
{ WM_INPUTLANGCHANGEREQUEST, L"WM_INPUTLANGCHANGEREQUEST" },
{ WM_INPUTLANGCHANGE, L"WM_INPUTLANGCHANGE" },
{ WM_TCARD, L"WM_TCARD" },
{ WM_HELP, L"WM_HELP" },
{ WM_USERCHANGED, L"WM_USERCHANGED" },
{ WM_NOTIFYFORMAT, L"WM_NOTIFYFORMAT" },
{ WM_CONTEXTMENU, L"WM_CONTEXTMENU" },
{ WM_STYLECHANGING, L"WM_STYLECHANGING" },
{ WM_STYLECHANGED, L"WM_STYLECHANGED" },
{ WM_DISPLAYCHANGE, L"WM_DISPLAYCHANGE" },
{ WM_GETICON, L"WM_GETICON" },
{ WM_SETICON, L"WM_SETICON" },
{ WM_NCCREATE, L"WM_NCCREATE" },
{ WM_NCDESTROY, L"WM_NCDESTROY" },
{ WM_NCCALCSIZE, L"WM_NCCALCSIZE" },
{ WM_NCHITTEST, L"WM_NCHITTEST" },
{ WM_NCPAINT, L"WM_NCPAINT" },
{ WM_NCACTIVATE, L"WM_NCACTIVATE" },
{ WM_GETDLGCODE, L"WM_GETDLGCODE" },
{ WM_SYNCPAINT, L"WM_SYNCPAINT" },
{ WM_NCMOUSEMOVE, L"WM_NCMOUSEMOVE" },
{ WM_NCLBUTTONDOWN, L"WM_NCLBUTTONDOWN" },
{ WM_NCLBUTTONUP, L"WM_NCLBUTTONUP" },
{ WM_NCLBUTTONDBLCLK, L"WM_NCLBUTTONDBLCLK" },
{ WM_NCRBUTTONDOWN, L"WM_NCRBUTTONDOWN" },
{ WM_NCRBUTTONUP, L"WM_NCRBUTTONUP" },
{ WM_NCRBUTTONDBLCLK, L"WM_NCRBUTTONDBLCLK" },
{ WM_NCMBUTTONDOWN, L"WM_NCMBUTTONDOWN" },
{ WM_NCMBUTTONUP, L"WM_NCMBUTTONUP" },
{ WM_NCMBUTTONDBLCLK, L"WM_NCMBUTTONDBLCLK" },
{ WM_NCXBUTTONDOWN, L"WM_NCXBUTTONDOWN" },
{ WM_NCXBUTTONUP, L"WM_NCXBUTTONUP" },
{ WM_NCXBUTTONDBLCLK, L"WM_NCXBUTTONDBLCLK" },
{ WM_INPUT_DEVICE_CHANGE, L"WM_INPUT_DEVICE_CHANGE" },
{ WM_INPUT, L"WM_INPUT" },
{ WM_KEYFIRST, L"WM_KEYFIRST" },
{ WM_KEYDOWN, L"WM_KEYDOWN" },
{ WM_KEYUP, L"WM_KEYUP" },
{ WM_CHAR, L"WM_CHAR" },
{ WM_DEADCHAR, L"WM_DEADCHAR" },
{ WM_SYSKEYDOWN, L"WM_SYSKEYDOWN" },
{ WM_SYSKEYUP, L"WM_SYSKEYUP" },
{ WM_SYSCHAR, L"WM_SYSCHAR" },
{ WM_SYSDEADCHAR, L"WM_SYSDEADCHAR" },
{ WM_KEYLAST, L"WM_KEYLAST" },
{ WM_KEYLAST, L"WM_KEYLAST" },
{ WM_IME_STARTCOMPOSITION, L"WM_IME_STARTCOMPOSITION" },
{ WM_IME_ENDCOMPOSITION, L"WM_IME_ENDCOMPOSITION" },
{ WM_IME_COMPOSITION, L"WM_IME_COMPOSITION" },
{ WM_IME_KEYLAST, L"WM_IME_KEYLAST" },
{ WM_INITDIALOG, L"WM_INITDIALOG" },
{ WM_COMMAND, L"WM_COMMAND" },
{ WM_SYSCOMMAND, L"WM_SYSCOMMAND" },
{ WM_TIMER, L"WM_TIMER" },
{ WM_HSCROLL, L"WM_HSCROLL" },
{ WM_VSCROLL, L"WM_VSCROLL" },
{ WM_INITMENU, L"WM_INITMENU" },
{ WM_INITMENUPOPUP, L"WM_INITMENUPOPUP" },
{ WM_GESTURE, L"WM_GESTURE" },
{ WM_GESTURENOTIFY, L"WM_GESTURENOTIFY" },
{ WM_MENUSELECT, L"WM_MENUSELECT" },
{ WM_MENUCHAR, L"WM_MENUCHAR" },
{ WM_ENTERIDLE, L"WM_ENTERIDLE" },
{ WM_MENURBUTTONUP, L"WM_MENURBUTTONUP" },
{ WM_MENUDRAG, L"WM_MENUDRAG" },
{ WM_MENUGETOBJECT, L"WM_MENUGETOBJECT" },
{ WM_UNINITMENUPOPUP, L"WM_UNINITMENUPOPUP" },
{ WM_MENUCOMMAND, L"WM_MENUCOMMAND" },
{ WM_CHANGEUISTATE, L"WM_CHANGEUISTATE" },
{ WM_UPDATEUISTATE, L"WM_UPDATEUISTATE" },
{ WM_QUERYUISTATE, L"WM_QUERYUISTATE" },
{ WM_CTLCOLORMSGBOX, L"WM_CTLCOLORMSGBOX" },
{ WM_CTLCOLOREDIT, L"WM_CTLCOLOREDIT" },
{ WM_CTLCOLORLISTBOX, L"WM_CTLCOLORLISTBOX" },
{ WM_CTLCOLORBTN, L"WM_CTLCOLORBTN" },
{ WM_CTLCOLORDLG, L"WM_CTLCOLORDLG" },
{ WM_CTLCOLORSCROLLBAR, L"WM_CTLCOLORSCROLLBAR" },
{ WM_CTLCOLORSTATIC, L"WM_CTLCOLORSTATIC" },
{ MN_GETHMENU, L"MN_GETHMENU" },
{ WM_MOUSEMOVE, L"WM_MOUSEMOVE" },
{ WM_LBUTTONDOWN, L"WM_LBUTTONDOWN" },
{ WM_LBUTTONUP, L"WM_LBUTTONUP" },
{ WM_LBUTTONDBLCLK, L"WM_LBUTTONDBLCLK" },
{ WM_RBUTTONDOWN, L"WM_RBUTTONDOWN" },
{ WM_RBUTTONUP, L"WM_RBUTTONUP" },
{ WM_RBUTTONDBLCLK, L"WM_RBUTTONDBLCLK" },
{ WM_MBUTTONDOWN, L"WM_MBUTTONDOWN" },
{ WM_MBUTTONUP, L"WM_MBUTTONUP" },
{ WM_MBUTTONDBLCLK, L"WM_MBUTTONDBLCLK" },
{ WM_MOUSEWHEEL, L"WM_MOUSEWHEEL" },
{ WM_XBUTTONDOWN, L"WM_XBUTTONDOWN" },
{ WM_XBUTTONUP, L"WM_XBUTTONUP" },
{ WM_XBUTTONDBLCLK, L"WM_XBUTTONDBLCLK" },
{ WM_MOUSEHWHEEL, L"WM_MOUSEHWHEEL" },
{ WM_PARENTNOTIFY, L"WM_PARENTNOTIFY" },
{ WM_ENTERMENULOOP, L"WM_ENTERMENULOOP" },
{ WM_EXITMENULOOP, L"WM_EXITMENULOOP" },
{ WM_NEXTMENU, L"WM_NEXTMENU" },
{ WM_SIZING, L"WM_SIZING" },
{ WM_CAPTURECHANGED, L"WM_CAPTURECHANGED" },
{ WM_MOVING, L"WM_MOVING" },
{ WM_POWERBROADCAST, L"WM_POWERBROADCAST" },
{ WM_DEVICECHANGE, L"WM_DEVICECHANGE" },
{ WM_MDICREATE, L"WM_MDICREATE" },
{ WM_MDIDESTROY, L"WM_MDIDESTROY" },
{ WM_MDIACTIVATE, L"WM_MDIACTIVATE" },
{ WM_MDIRESTORE, L"WM_MDIRESTORE" },
{ WM_MDINEXT, L"WM_MDINEXT" },
{ WM_MDIMAXIMIZE, L"WM_MDIMAXIMIZE" },
{ WM_MDITILE, L"WM_MDITILE" },
{ WM_MDICASCADE, L"WM_MDICASCADE" },
{ WM_MDIICONARRANGE, L"WM_MDIICONARRANGE" },
{ WM_MDIGETACTIVE, L"WM_MDIGETACTIVE" },
{ WM_MDISETMENU, L"WM_MDISETMENU" },
{ WM_ENTERSIZEMOVE, L"WM_ENTERSIZEMOVE" },
{ WM_EXITSIZEMOVE, L"WM_EXITSIZEMOVE" },
{ WM_DROPFILES, L"WM_DROPFILES" },
{ WM_MDIREFRESHMENU, L"WM_MDIREFRESHMENU" },
{ WM_POINTERDEVICECHANGE, L"WM_POINTERDEVICECHANGE" },
{ WM_POINTERDEVICEINRANGE, L"WM_POINTERDEVICEINRANGE" },
{ WM_POINTERDEVICEOUTOFRANGE, L"WM_POINTERDEVICEOUTOFRANGE" },
{ WM_TOUCH, L"WM_TOUCH" },
{ WM_NCPOINTERUPDATE, L"WM_NCPOINTERUPDATE" },
{ WM_NCPOINTERDOWN, L"WM_NCPOINTERDOWN" },
{ WM_NCPOINTERUP, L"WM_NCPOINTERUP" },
{ WM_POINTERUPDATE, L"WM_POINTERUPDATE" },
{ WM_POINTERDOWN, L"WM_POINTERDOWN" },
{ WM_POINTERUP, L"WM_POINTERUP" },
{ WM_POINTERENTER, L"WM_POINTERENTER" },
{ WM_POINTERLEAVE, L"WM_POINTERLEAVE" },
{ WM_POINTERACTIVATE, L"WM_POINTERACTIVATE" },
{ WM_POINTERCAPTURECHANGED, L"WM_POINTERCAPTURECHANGED" },
{ WM_TOUCHHITTESTING, L"WM_TOUCHHITTESTING" },
{ WM_POINTERWHEEL, L"WM_POINTERWHEEL" },
{ WM_POINTERHWHEEL, L"WM_POINTERHWHEEL" },
{ DM_POINTERHITTEST, L"DM_POINTERHITTEST" },
{ WM_IME_SETCONTEXT, L"WM_IME_SETCONTEXT" },
{ WM_IME_NOTIFY, L"WM_IME_NOTIFY" },
{ WM_IME_CONTROL, L"WM_IME_CONTROL" },
{ WM_IME_COMPOSITIONFULL, L"WM_IME_COMPOSITIONFULL" },
{ WM_IME_SELECT, L"WM_IME_SELECT" },
{ WM_IME_CHAR, L"WM_IME_CHAR" },
{ WM_IME_REQUEST, L"WM_IME_REQUEST" },
{ WM_IME_KEYDOWN, L"WM_IME_KEYDOWN" },
{ WM_IME_KEYUP, L"WM_IME_KEYUP" },
{ WM_MOUSEHOVER, L"WM_MOUSEHOVER" },
{ WM_MOUSELEAVE, L"WM_MOUSELEAVE" },
{ WM_NCMOUSEHOVER, L"WM_NCMOUSEHOVER" },
{ WM_NCMOUSELEAVE, L"WM_NCMOUSELEAVE" },
{ WM_WTSSESSION_CHANGE, L"WM_WTSSESSION_CHANGE" },
{ WM_TABLET_FIRST, L"WM_TABLET_FIRST" },
{ WM_TABLET_LAST, L"WM_TABLET_LAST" },
{ WM_DPICHANGED, L"WM_DPICHANGED" },
{ WM_CUT, L"WM_CUT" },
{ WM_COPY, L"WM_COPY" },
{ WM_PASTE, L"WM_PASTE" },
{ WM_CLEAR, L"WM_CLEAR" },
{ WM_UNDO, L"WM_UNDO" },
{ WM_RENDERFORMAT, L"WM_RENDERFORMAT" },
{ WM_RENDERALLFORMATS, L"WM_RENDERALLFORMATS" },
{ WM_DESTROYCLIPBOARD, L"WM_DESTROYCLIPBOARD" },
{ WM_DRAWCLIPBOARD, L"WM_DRAWCLIPBOARD" },
{ WM_PAINTCLIPBOARD, L"WM_PAINTCLIPBOARD" },
{ WM_VSCROLLCLIPBOARD, L"WM_VSCROLLCLIPBOARD" },
{ WM_SIZECLIPBOARD, L"WM_SIZECLIPBOARD" },
{ WM_ASKCBFORMATNAME, L"WM_ASKCBFORMATNAME" },
{ WM_CHANGECBCHAIN, L"WM_CHANGECBCHAIN" },
{ WM_HSCROLLCLIPBOARD, L"WM_HSCROLLCLIPBOARD" },
{ WM_QUERYNEWPALETTE, L"WM_QUERYNEWPALETTE" },
{ WM_PALETTEISCHANGING, L"WM_PALETTEISCHANGING" },
{ WM_PALETTECHANGED, L"WM_PALETTECHANGED" },
{ WM_HOTKEY, L"WM_HOTKEY" },
{ WM_PRINT, L"WM_PRINT" },
{ WM_PRINTCLIENT, L"WM_PRINTCLIENT" },
{ WM_APPCOMMAND, L"WM_APPCOMMAND" },
{ WM_THEMECHANGED, L"WM_THEMECHANGED" },
{ WM_CLIPBOARDUPDATE, L"WM_CLIPBOARDUPDATE" },
{ WM_DWMCOMPOSITIONCHANGED, L"WM_DWMCOMPOSITIONCHANGED" },
{ WM_DWMNCRENDERINGCHANGED, L"WM_DWMNCRENDERINGCHANGED" },
{ WM_DWMCOLORIZATIONCOLORCHANGED, L"WM_DWMCOLORIZATIONCOLORCHANGED" },
{ WM_DWMWINDOWMAXIMIZEDCHANGE, L"WM_DWMWINDOWMAXIMIZEDCHANGE" },
{ WM_DWMSENDICONICTHUMBNAIL, L"WM_DWMSENDICONICTHUMBNAIL" },
{ WM_DWMSENDICONICLIVEPREVIEWBITMAP, L"WM_DWMSENDICONICLIVEPREVIEWBITMAP" },
{ WM_GETTITLEBARINFOEX, L"WM_GETTITLEBARINFOEX" },
{ WM_HANDHELDFIRST, L"WM_HANDHELDFIRST" },
{ WM_HANDHELDLAST, L"WM_HANDHELDLAST" },
{ WM_AFXFIRST, L"WM_AFXFIRST" },
{ WM_AFXLAST, L"WM_AFXLAST" },
{ WM_PENWINFIRST, L"WM_PENWINFIRST" },
{ WM_PENWINLAST, L"WM_PENWINLAST" },
{ WM_APP, L"WM_APP" }
};
inline std::wstring DebugHelper::FormatWindowMessage(MSG msg)
{
std::wstringstream wss;
wss << L"hwnd: " << std::setw(8) << std::setfill(L'0') << std::hex << msg.hwnd << L"; ";
auto messagecode = kWindowsMessageCodeMap.find(msg.message) == kWindowsMessageCodeMap.end() ? L"" : L" (" + kWindowsMessageCodeMap.at(msg.message) + L")";
wss << L"message: " << std::setw(8) << std::setfill(L'0') << std::hex << msg.message<< messagecode << L"; ";
wss << L"wParam: " << std::setw(8) << std::setfill(L'0') << std::hex << msg.wParam << L"; ";
wss << L"lParam: " << std::setw(8) << std::setfill(L'0') << std::hex << msg.lParam << L"; ";
wss << L"time: " << msg.time << L"; ";
wss << L"pt: (" << msg.pt.x << L", " << msg.pt.y << ")";
return wss.str();
}
inline std::wstring DebugHelper::FormatWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
std::wstringstream wss;
auto messagecode = kWindowsMessageCodeMap.find(uMsg) == kWindowsMessageCodeMap.end() ? L"" : L" (" + kWindowsMessageCodeMap.at(uMsg) + L")";
wss << L"message: " << std::setw(8) << std::setfill(L'0') << std::hex << uMsg << messagecode << L"; ";
wss << L"wParam: " << std::setw(8) << std::setfill(L'0') << std::hex << wParam << L"; ";
wss << L"lParam: " << std::setw(8) << std::setfill(L'0') << std::hex << lParam << L"; ";
return wss.str();
}