From 1a3cb2be4de7e6945372aa5292dbe13b691c9f86 Mon Sep 17 00:00:00 2001 From: narzoul Date: Wed, 6 Apr 2016 22:35:54 +0200 Subject: [PATCH] Added invalidation of non-client area on WM_ACTIVATE --- DDrawCompat/CompatGdiWinProc.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/CompatGdiWinProc.cpp index ae6e9c4..cd5064b 100644 --- a/DDrawCompat/CompatGdiWinProc.cpp +++ b/DDrawCompat/CompatGdiWinProc.cpp @@ -18,6 +18,7 @@ namespace std::unordered_map g_prevWindowRect; void disableDwmAttributes(HWND hwnd); + void onActivate(HWND hwnd); void onMenuSelect(); void onWindowPosChanged(HWND hwnd); void removeDropShadow(HWND hwnd); @@ -43,6 +44,10 @@ namespace { onWindowPosChanged(ret->hwnd); } + else if (WM_ACTIVATE == ret->message) + { + onActivate(ret->hwnd); + } else if (WM_COMMAND == ret->message) { auto notifCode = HIWORD(ret->wParam); @@ -95,7 +100,7 @@ namespace { if (OBJID_TITLEBAR == idObject) { - CompatGdi::TitleBar(hwnd, compatDc).drawAll(); + CompatGdi::TitleBar(hwnd, compatDc).drawButtons(); } else if (OBJID_HSCROLL == idObject) { @@ -113,6 +118,24 @@ namespace } } + void onActivate(HWND hwnd) + { + RECT windowRect = {}; + GetWindowRect(hwnd, &windowRect); + RECT clientRect = {}; + GetClientRect(hwnd, &clientRect); + POINT clientOrigin = {}; + ClientToScreen(hwnd, &clientOrigin); + OffsetRect(&windowRect, -clientOrigin.x, -clientOrigin.y); + + HRGN ncRgn = CreateRectRgnIndirect(&windowRect); + HRGN clientRgn = CreateRectRgnIndirect(&clientRect); + CombineRgn(ncRgn, ncRgn, clientRgn, RGN_DIFF); + RedrawWindow(hwnd, nullptr, ncRgn, RDW_FRAME | RDW_INVALIDATE); + DeleteObject(clientRgn); + DeleteObject(ncRgn); + } + void onMenuSelect() { HWND menuWindow = FindWindow(reinterpret_cast(0x8000), nullptr);