From 9fa1a8a047f678b250c6283dd063abf3db7c955c Mon Sep 17 00:00:00 2001 From: narzoul Date: Thu, 13 May 2021 23:00:23 +0200 Subject: [PATCH] Fixed GDI brush origin Fixes splash window background alignment in Star Trek: Armada. See issue #94. --- DDrawCompat/Gdi/Dc.cpp | 2 +- DDrawCompat/Gdi/User32WndProcs.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/DDrawCompat/Gdi/Dc.cpp b/DDrawCompat/Gdi/Dc.cpp index e8864e7..1cc1c38 100644 --- a/DDrawCompat/Gdi/Dc.cpp +++ b/DDrawCompat/Gdi/Dc.cpp @@ -90,7 +90,7 @@ namespace POINT brushOrg = {}; GetBrushOrgEx(origDc, &brushOrg); - SetBrushOrgEx(compatDc.dc, brushOrg.x, brushOrg.y, nullptr); + SetBrushOrgEx(compatDc.dc, origin.x + brushOrg.x, origin.y + brushOrg.y, nullptr); POINT currentPos = {}; GetCurrentPositionEx(origDc, ¤tPos); diff --git a/DDrawCompat/Gdi/User32WndProcs.cpp b/DDrawCompat/Gdi/User32WndProcs.cpp index 13ec07d..236b897 100644 --- a/DDrawCompat/Gdi/User32WndProcs.cpp +++ b/DDrawCompat/Gdi/User32WndProcs.cpp @@ -156,6 +156,19 @@ namespace } break; + case WM_ERASEBKGND: + { + HBRUSH brush = reinterpret_cast(GetClassLong(hwnd, GCL_HBRBACKGROUND)); + if (!brush) + { + return FALSE; + } + RECT rect = {}; + GetClientRect(hwnd, &rect); + FillRect(Gdi::CompatDc(reinterpret_cast(wParam)), &rect, brush); + return TRUE; + } + case WM_NCACTIVATE: return onNcActivate(hwnd, wParam, lParam);