From 7555fb02d290f5dc9bcb28cdd4628258b6630d91 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sat, 23 Jan 2016 20:40:01 +0100 Subject: [PATCH] Fixed scrollbars not updating when scrolling The nonclient area is now also invalidated when scrolling. Added similar handling for WM_MOUSEWHEEL messages. --- DDrawCompat/CompatGdiWinProc.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/CompatGdiWinProc.cpp index 54ac958..1cda7dd 100644 --- a/DDrawCompat/CompatGdiWinProc.cpp +++ b/DDrawCompat/CompatGdiWinProc.cpp @@ -10,7 +10,8 @@ namespace { void eraseBackground(HWND hwnd, HDC dc); - void ncPaint(HWND wnd); + void ncPaint(HWND hwnd); + void updateScrolledWindow(HWND hwnd); LRESULT CALLBACK callWndRetProc(int nCode, WPARAM wParam, LPARAM lParam) { @@ -37,7 +38,7 @@ namespace } else if (WM_VSCROLL == ret->message || WM_HSCROLL == ret->message) { - InvalidateRect(ret->hwnd, nullptr, TRUE); + updateScrolledWindow(ret->hwnd); } } @@ -58,6 +59,20 @@ namespace } } + LRESULT CALLBACK mouseProc(int nCode, WPARAM wParam, LPARAM lParam) + { + if (HC_ACTION == nCode) + { + auto mhs = reinterpret_cast(lParam); + if (WM_MOUSEWHEEL == wParam) + { + updateScrolledWindow(mhs->hwnd); + } + } + + return CallNextHookEx(nullptr, nCode, wParam, lParam); + } + void ncPaint(HWND hwnd) { if (!CompatGdi::beginGdiRendering()) @@ -88,6 +103,11 @@ namespace ReleaseDC(hwnd, windowDc); CompatGdi::endGdiRendering(); } + + void updateScrolledWindow(HWND hwnd) + { + RedrawWindow(hwnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE); + } } namespace CompatGdiWinProc @@ -96,5 +116,6 @@ namespace CompatGdiWinProc { const DWORD threadId = GetCurrentThreadId(); SetWindowsHookEx(WH_CALLWNDPROCRET, callWndRetProc, nullptr, threadId); + SetWindowsHookEx(WH_MOUSE, &mouseProc, nullptr, threadId); } }