From 941b55f5464b0e3f89f4e51dda75d2d1aa4becc4 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 14 Feb 2016 20:26:15 +0100 Subject: [PATCH] Improved detection of scrolling events --- DDrawCompat/CompatGdiFunctions.cpp | 31 ++++++++++++++++++++++++++++++ DDrawCompat/CompatGdiWinProc.cpp | 11 ++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/DDrawCompat/CompatGdiFunctions.cpp b/DDrawCompat/CompatGdiFunctions.cpp index 9c725f1..e7126a8 100644 --- a/DDrawCompat/CompatGdiFunctions.cpp +++ b/DDrawCompat/CompatGdiFunctions.cpp @@ -82,8 +82,37 @@ namespace { return &compatGdiFunc; } + + BOOL WINAPI scrollWindow( + _In_ HWND hWnd, + _In_ int XAmount, + _In_ int YAmount, + _In_ const RECT *lpRect, + _In_ const RECT *lpClipRect) + { + InvalidateRect(hWnd, nullptr, TRUE); + return CALL_ORIG_GDI(ScrollWindow)(hWnd, XAmount, YAmount, lpRect, lpClipRect); + } + + int WINAPI scrollWindowEx( + _In_ HWND hWnd, + _In_ int dx, + _In_ int dy, + _In_ const RECT *prcScroll, + _In_ const RECT *prcClip, + _In_ HRGN hrgnUpdate, + _Out_ LPRECT prcUpdate, + _In_ UINT flags) + { + InvalidateRect(hWnd, nullptr, TRUE); + return CALL_ORIG_GDI(ScrollWindowEx)(hWnd, dx, dy, prcScroll, prcClip, hrgnUpdate, prcUpdate, flags); + } } +#define HOOK_GDI_FUNCTION_CUSTOM(module, func, newFunc) \ + CompatGdi::hookGdiFunction( \ + #module, #func, &newFunc); + #define HOOK_GDI_FUNCTION(module, func) \ CompatGdi::hookGdiFunction( \ #module, #func, getCompatGdiFuncPtr(&func)); @@ -182,6 +211,8 @@ namespace CompatGdiFunctions // Scroll bar functions HOOK_GDI_FUNCTION(user32, ScrollDC); + HOOK_GDI_FUNCTION_CUSTOM(user32, ScrollWindow, scrollWindow); + HOOK_GDI_FUNCTION_CUSTOM(user32, ScrollWindowEx, scrollWindowEx); DetourTransactionCommit(); } diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/CompatGdiWinProc.cpp index 29535d5..dc0c2a8 100644 --- a/DDrawCompat/CompatGdiWinProc.cpp +++ b/DDrawCompat/CompatGdiWinProc.cpp @@ -48,6 +48,15 @@ namespace { updateScrolledWindow(ret->hwnd); } + else if (WM_COMMAND == ret->message) + { + auto msgSource = LOWORD(ret->wParam); + auto notifCode = HIWORD(ret->wParam); + if (0 != msgSource && 1 != msgSource && (EN_HSCROLL == notifCode || EN_VSCROLL == notifCode)) + { + updateScrolledWindow(reinterpret_cast(ret->lParam)); + } + } } return CallNextHookEx(nullptr, nCode, wParam, lParam); @@ -83,7 +92,7 @@ namespace if (HC_ACTION == nCode) { auto mhs = reinterpret_cast(lParam); - if (WM_MOUSEWHEEL == wParam) + if (WM_MOUSEWHEEL == wParam || WM_MOUSEHWHEEL == wParam) { updateScrolledWindow(mhs->hwnd); }