From 18d6af8d54bce0d270e495013370e76910713617 Mon Sep 17 00:00:00 2001 From: RadAd Date: Mon, 15 Jul 2019 10:57:33 +1000 Subject: Fix for WM_MOUSEACTIVATE with MDI child windows --- RadTerminal.cpp | 13 ++++++++----- RadTerminal.vcxproj | 4 ++++ RadTerminalFrame.cpp | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RadTerminal.cpp b/RadTerminal.cpp index 012888e..05ebfd5 100644 --- a/RadTerminal.cpp +++ b/RadTerminal.cpp @@ -169,7 +169,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pCmdLine, int nCmdSho HWND hWnd = NULL; HWND hWndMDIClient = NULL; HACCEL hAccel = NULL; - bool bMDI = true; + bool bMDI = false; CHECK(GetRadTerminalAtom(hInstance), EXIT_FAILURE); @@ -190,7 +190,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pCmdLine, int nCmdSho CHECK(UnadjustWindowRectEx(&r, GetWindowStyle(hChildWnd), GetMenu(hChildWnd) != NULL, GetWindowExStyle(hChildWnd)), EXIT_FAILURE); CHECK(AdjustWindowRectEx(&r, GetWindowStyle(hWnd), GetMenu(hWnd) != NULL, GetWindowExStyle(hWnd)), EXIT_FAILURE); CHECK(SetWindowPos(hWnd, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOMOVE | SWP_NOZORDER), EXIT_FAILURE); - CHECK(ShowWindow(hChildWnd, SW_MAXIMIZE), EXIT_FAILURE); + ShowWindow(hChildWnd, SW_MAXIMIZE); } } else @@ -210,10 +210,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pCmdLine, int nCmdSho ); CHECK(hWnd, EXIT_FAILURE); - CHECK(ShowWindow(hWnd, nCmdShow), EXIT_FAILURE); + ShowWindow(hWnd, nCmdShow); } - MSG msg = {}; while (GetMessage(&msg, (HWND) NULL, 0, 0)) { @@ -1023,8 +1022,12 @@ void RadTerminalWindowOnKeyDown(HWND hWnd, UINT vk, BOOL fDown, int cRepeat, UIN int RadTerminalWindowOnMouseActivate(HWND hWnd, HWND hwndTopLevel, UINT codeHitTest, UINT msg) { int result = FORWARD_WM_MOUSEACTIVATE(hWnd, hwndTopLevel, codeHitTest, msg, MyDefWindowProc); - if (result == MA_ACTIVATE && codeHitTest == HTCLIENT) + static HWND s_hWnd = NULL; // MDI Windows get a WM_MOUSE_ACTIVATE on every mouse click, not just the first to make it active + if (s_hWnd != hWnd && result == MA_ACTIVATE && codeHitTest == HTCLIENT) + { + s_hWnd = hWnd; return MA_ACTIVATEANDEAT; + } return result; } diff --git a/RadTerminal.vcxproj b/RadTerminal.vcxproj index 9b27af0..b5f092b 100644 --- a/RadTerminal.vcxproj +++ b/RadTerminal.vcxproj @@ -78,6 +78,8 @@ true + kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;%(AdditionalDependencies) @@ -91,6 +93,8 @@ true true true + kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;uxtheme.lib;%(AdditionalDependencies) diff --git a/RadTerminalFrame.cpp b/RadTerminalFrame.cpp index defcd0e..9ed7ebf 100644 --- a/RadTerminalFrame.cpp +++ b/RadTerminalFrame.cpp @@ -59,6 +59,8 @@ BOOL RadTerminalFrameOnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) HWND hWndMDIClient = CreateWindow(TEXT("MDICLIENT"), (LPCTSTR) NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, 0, 0, 0, 0, hWnd, (HMENU) 0, hInst, (LPSTR) &ccs); + if (hWndMDIClient == NULL) + return FALSE; ShowWindow(hWndMDIClient, SW_SHOW); -- cgit v1.2.3