From 4aa5e04da102017852fb1856b87c95fe66bddb04 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Thu, 20 Feb 2020 12:39:02 +0800 Subject: [PATCH] add dump_mouse_message, dump_message_with_retval, dump_message, and dump_window functions (static inline) --- src/include/debug.h | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/src/include/debug.h b/src/include/debug.h index 3b66410d..cc2aed8a 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -54,6 +54,12 @@ #include +#include "common.h" +#include "minigui.h" +#include "gdi.h" +#include "window.h" +#include "internals.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -74,6 +80,106 @@ static inline void dump_rect (const RECT* rect, const char* name) RECTWP(rect), RECTHP(rect)); } +static inline void dump_window (HWND hwnd, const char* name) +{ + PMAINWIN main_win = (PMAINWIN)hwnd; + + if (hwnd == HWND_NULL) { + _WRN_PRINTF("window for %s: (nil)\n", name); + return; + } + else if (hwnd == HWND_INVALID) { + _WRN_PRINTF("window for %s: (invalid)\n", name); + return; + } + else if (main_win->DataType != TYPE_HWND) { + _WRN_PRINTF("window for %s: not a window (datatype: %d)\n", name, + (int)main_win->DataType); + return; + } + + switch (main_win->WinType) { + case TYPE_MAINWIN: + _WRN_PRINTF("A main window for %s: " + "caption(%s), id(%ld), positon(%d, %d, %d, %d)\n", + name, main_win->spCaption, main_win->id, + main_win->left, main_win->top, + main_win->right, main_win->bottom); + break; + + case TYPE_VIRTWIN: + _WRN_PRINTF("A virtual window for %s: " + "caption(%s), id(%ld)\n", + name, main_win->spCaption, main_win->id); + break; + + case TYPE_CONTROL: + _WRN_PRINTF("A control for %s: " + "caption(%s), id(%ld), positon(%d, %d, %d, %d)\n", + name, main_win->spCaption, main_win->id, + main_win->left, main_win->top, + main_win->right, main_win->bottom); + break; + + case TYPE_ROOTWIN: + _WRN_PRINTF("A root window for %s: " + "caption(%s), id(%ld), positon(%d, %d, %d, %d)\n", + name, main_win->spCaption, main_win->id, + main_win->left, main_win->top, + main_win->right, main_win->bottom); + break; + + default: + _WRN_PRINTF("A unknown window for %s: %p\n", + name, main_win); + break; + } +} + +static inline void dump_message (const MSG* msg, const char* name) +{ +#ifdef _MGHAVE_MSG_STRING + _WRN_PRINTF ("Message(%s) for %s: %u (%s), Wnd: %p, wP: %p, lP: %p.\n", + msg->pAdd?"SYNC":"NORM", + name, msg->message, Message2Str (msg->message), + msg->hwnd, (PVOID)msg->wParam, (PVOID)msg->lParam); +#else + _WRN_PRINTF ("Message(%S) for %s: %u, Wnd: %p, wP: %p, lP: %p.\n", + msg->pAdd?"SYNC":"NORM", + name, msg->message, + msg->hwnd, (PVOID)msg->wParam, (PVOID)msg->lParam); +#endif +} + +static inline void dump_message_with_retval (const MSG* msg, LRESULT retval, + const char* name) +{ +#ifdef _MGHAVE_MSG_STRING + _WRN_PRINTF ("Message(%s) for %s done: %u (%s), Wnd: %p, retval (%p).\n", + msg->pAdd?"SYNC":"NORM", + name, msg->message, Message2Str (msg->message), + msg->hwnd, (PVOID)retval); +#else + _WRN_PRINTF ("Message(%S) for %s: %u, Wnd: %p, retval (%p).\n", + msg->pAdd?"SYNC":"NORM", + name, msg->message, + msg->hwnd, (PVOID)retval); +#endif +} + +static inline void dump_mouse_message (UINT message, int location, int x, int y, + const char* name) +{ +#ifdef _MGHAVE_MSG_STRING + _WRN_PRINTF ("Mouse message for %s: %u (%s), location(%d), x(%d), y(%d).\n", + name, message, Message2Str (message), + location, x, y); +#else + _WRN_PRINTF ("Mouse message for %s: %u, location(%d), x(%d), y(%d).\n", + name, message, location, x, y); +#endif +} + #ifdef __cplusplus } #endif /* __cplusplus */