From 71586cc9949e45f4dd937a641405f6dd00b2d20a Mon Sep 17 00:00:00 2001 From: narzoul Date: Sat, 19 Mar 2016 18:59:04 +0100 Subject: [PATCH] Hooked PolyPatBlt Makes the button highlight workaround unnecessary. --- DDrawCompat/CompatGdiDcFunctions.cpp | 5 ++++ DDrawCompat/CompatGdiWinProc.cpp | 44 +++++++++------------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/DDrawCompat/CompatGdiDcFunctions.cpp b/DDrawCompat/CompatGdiDcFunctions.cpp index 1bdad1c..415a2d2 100644 --- a/DDrawCompat/CompatGdiDcFunctions.cpp +++ b/DDrawCompat/CompatGdiDcFunctions.cpp @@ -8,6 +8,8 @@ namespace { + BOOL WINAPI PolyPatBlt(HDC, DWORD, DWORD, DWORD, DWORD) { return FALSE; } + template using FuncPtr = Result(WINAPI *)(Params...); @@ -208,6 +210,9 @@ namespace CompatGdiDcFunctions // Scroll bar functions HOOK_GDI_DC_FUNCTION(user32, ScrollDC); + // Undocumented functions + HOOK_GDI_DC_FUNCTION(gdi32, PolyPatBlt); + DetourTransactionCommit(); } } diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/CompatGdiWinProc.cpp index a5d1382..4137170 100644 --- a/DDrawCompat/CompatGdiWinProc.cpp +++ b/DDrawCompat/CompatGdiWinProc.cpp @@ -93,19 +93,6 @@ namespace &disableTransitions, sizeof(disableTransitions)); } - bool drawButtonHighlight(HWND hwnd, const RECT& windowRect, HDC compatDc) - { - if (SendMessage(hwnd, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) - { - RECT rect = {}; - SetRect(&rect, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); - FrameRect(compatDc, &rect, GetSysColorBrush(COLOR_WINDOWFRAME)); - return true; - } - - return false; - } - void eraseBackground(HWND hwnd, HDC dc) { if (CompatGdi::beginGdiRendering()) @@ -149,26 +136,23 @@ namespace RECT windowRect = {}; GetWindowRect(hwnd, &windowRect); - if (!drawButtonHighlight(hwnd, windowRect, compatDc)) - { - CompatGdi::TitleBar titleBar(hwnd, compatDc); - titleBar.drawAll(); - titleBar.excludeFromClipRegion(); + CompatGdi::TitleBar titleBar(hwnd, compatDc); + titleBar.drawAll(); + titleBar.excludeFromClipRegion(); - CompatGdi::ScrollBar scrollBar(hwnd, compatDc); - scrollBar.drawAll(); - scrollBar.excludeFromClipRegion(); + CompatGdi::ScrollBar scrollBar(hwnd, compatDc); + scrollBar.drawAll(); + scrollBar.excludeFromClipRegion(); - RECT clientRect = {}; - GetClientRect(hwnd, &clientRect); - POINT clientOrigin = {}; - ClientToScreen(hwnd, &clientOrigin); + RECT clientRect = {}; + GetClientRect(hwnd, &clientRect); + POINT clientOrigin = {}; + ClientToScreen(hwnd, &clientOrigin); - OffsetRect(&clientRect, clientOrigin.x - windowRect.left, clientOrigin.y - windowRect.top); - ExcludeClipRect(compatDc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom); - CALL_ORIG_GDI(BitBlt)(compatDc, 0, 0, - windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, windowDc, 0, 0, SRCCOPY); - } + OffsetRect(&clientRect, clientOrigin.x - windowRect.left, clientOrigin.y - windowRect.top); + ExcludeClipRect(compatDc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom); + CALL_ORIG_GDI(BitBlt)(compatDc, 0, 0, + windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, windowDc, 0, 0, SRCCOPY); CompatGdiDc::releaseDc(windowDc); }