2 * Copyright (c) 2005 Alexander Gottwald
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
22 * Except as contained in this notice, the name(s) of the above copyright
23 * holders shall not be used in advertising or otherwise to promote the sale,
24 * use or other dealings in this Software without prior written authorization.
28 std::string
win32_error::message(DWORD errorcode
)
32 FORMAT_MESSAGE_ALLOCATE_BUFFER
|
33 FORMAT_MESSAGE_FROM_SYSTEM
|
34 FORMAT_MESSAGE_IGNORE_INSERTS
,
37 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), // Default language
42 return "Unknown error in FormatMessage";
45 std::string
ret((LPCTSTR
)lpMsgBuf
);
46 LocalFree( lpMsgBuf
);
50 void MessageDebug::debug(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, const char *prefix
)
53 static const char *psn_notify
[] = {
64 if (uMsg
== WM_NOTIFY
)
66 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
67 int psn_index
= -(int)pnmh
->code
- 200;
68 if (psn_index
>= 0 && psn_index
< 10 && psn_notify
[psn_index
])
69 printf("%s: %08x %04x WM_NOTIFY (%s)\n", prefix
, hwnd
, wParam
, psn_notify
[psn_index
]);
70 else if (pnmh
->code
< NOTIFY_NAMES_LEN
&& notify_names
[pnmh
->code
])
71 printf("%s: %08x %04x WM_NOTIFY (%s)\n", prefix
, hwnd
, wParam
, notify_names
[pnmh
->code
]);
73 printf("%s: %08x %04x WM_NOTIFY (%u)\n", prefix
, hwnd
, wParam
, pnmh
->code
);
75 else if (uMsg
>= MESSAGE_NAMES_LEN
)
77 printf("%s: %08x %04x %08x WM_USER + %d\n", prefix
, hwnd
, wParam
, lParam
, uMsg
- WM_USER
);
79 printf("%s: %08x %04x %08x %d\n", prefix
, hwnd
, wParam
, lParam
, uMsg
);
80 else if (uMsg
>= 0 && uMsg
< MESSAGE_NAMES_LEN
&& message_names
[uMsg
])
81 printf("%s: %08x %04x %08x %s\n", prefix
, hwnd
, wParam
, lParam
, message_names
[uMsg
]);
86 const char * MessageDebug::message_names
[MESSAGE_NAMES_LEN
] = {
104 "WM_QUERYENDSESSION",
119 NULL
/* WM_SETCURSOR */,
157 "WM_WINDOWPOSCHANGING",
158 "WM_WINDOWPOSCHANGED",
167 "WM_INPUTLANGCHANGEREQUEST",
168 "WM_INPUTLANGCHANGE",
219 NULL
/* WM_NCHITTEST */,
247 NULL
/* WM_NCMOUSEMOVE */,
250 "WM_NCLBUTTONDBLCLK",
253 "WM_NCRBUTTONDBLCLK",
256 "WM_NCMBUTTONDBLCLK",
351 "WM_CONVERTREQUESTEX",
356 "WM_IME_STARTCOMPOSITION",
357 "WM_IME_ENDCOMPOSITION",
395 "WM_CTLCOLORLISTBOX",
398 "WM_CTLCOLORSCROLLBAR",
599 NULL
/* WM_MOUSEMOVE */,
731 "WM_IME_COMPOSITIONFULL",
861 "WM_RENDERALLFORMATS",
862 "WM_DESTROYCLIPBOARD",
865 "WM_VSCROLLCLIPBOARD",
867 "WM_ASKCBFORMATNAME",
869 "WM_HSCROLLCLIPBOARD",
870 "WM_QUERYNEWPALETTE",
871 "WM_PALETTEISCHANGING",