From 19d82be4963a8cc49d81eb9ac104bf50dda5154a Mon Sep 17 00:00:00 2001 From: Takuma Murakami Date: Tue, 17 Feb 2004 06:26:17 +0000 Subject: [PATCH] Stop passing customized menus to DefWindowProc. Although it does not cause visible problems so far, it should be inhibited. Apply a mask, which is described in MSDN, for wParam in winTopLevelWindowProc/WM_SYSCOMMAND handler. --- hw/xwin/winmultiwindowwndproc.c | 19 +++++++++++++------ hw/xwin/winprefs.c | 19 ++++++++++--------- hw/xwin/winprefs.h | 2 +- hw/xwin/winwndproc.c | 3 ++- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index b74f258f3..82d7f930c 100755 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -387,23 +387,30 @@ winTopLevelWindowProc (HWND hwnd, UINT message, /* * Any window menu items go through here */ - /* If minimizing then remove always-on-top, and store the setting */ - if (wParam == SC_MINIMIZE) + switch (wParam & 0xFFF0) /* See MSDN for the magic number 0xFFF0 */ { + case SC_MINIMIZE: + /* If minimizing then remove always-on-top, and store the setting */ if (GetWindowLong (hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) pWinPriv->fAlwaysOnTop = TRUE; else pWinPriv->fAlwaysOnTop = FALSE; SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); - } - else if (wParam == SC_RESTORE) - { + break; + + case SC_RESTORE: if (pWinPriv->fAlwaysOnTop) SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + break; + + default: + if (HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam))) + /* Don't pass customized menus to DefWindowProc */ + return 0; + break; } - HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam)); break; case WM_INITMENU: diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index 67443ed54..6fb7f0c6c 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -284,9 +284,10 @@ HandleCustomWM_INITMENU(unsigned long hwndIn, } /* - * Searches for the custom WM_COMMAND command ID and performs action + * Searches for the custom WM_COMMAND command ID and performs action. + * Return TRUE if command is proccessed, FALSE otherwise. */ -int +Bool HandleCustomWM_COMMAND (unsigned long hwndIn, int command) { @@ -298,7 +299,7 @@ HandleCustomWM_COMMAND (unsigned long hwndIn, hwnd = (HWND)hwndIn; if (!command) - return 0; + return FALSE; for (i=0; i