1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Improved detection of scrolling events

This commit is contained in:
narzoul 2016-02-14 20:26:15 +01:00
parent 4a83a15d78
commit 941b55f546
2 changed files with 41 additions and 1 deletions

View File

@ -82,8 +82,37 @@ namespace
{
return &compatGdiFunc<OrigFuncPtr, origFunc, Result, Params...>;
}
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<decltype(&func), &func>( \
#module, #func, &newFunc);
#define HOOK_GDI_FUNCTION(module, func) \
CompatGdi::hookGdiFunction<decltype(&func), &func>( \
#module, #func, getCompatGdiFuncPtr<decltype(&func), &func>(&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();
}

View File

@ -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<HWND>(ret->lParam));
}
}
}
return CallNextHookEx(nullptr, nCode, wParam, lParam);
@ -83,7 +92,7 @@ namespace
if (HC_ACTION == nCode)
{
auto mhs = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam);
if (WM_MOUSEWHEEL == wParam)
if (WM_MOUSEWHEEL == wParam || WM_MOUSEHWHEEL == wParam)
{
updateScrolledWindow(mhs->hwnd);
}