From c63d36d831c6058c7b02f9319a20e9c5c7c7fba4 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 16 Jul 2017 22:39:56 +0200 Subject: [PATCH] Fixed issue with GDI controls not always being visible Reverted an earlier optimization that tried to handle WM_ERASEBKGND and WM_PAINT events in a single update cycle for reduced flickering. It caused some child controls to not display properly. Fixes an issue reported in #15. --- DDrawCompat/Gdi/PaintHandlers.cpp | 38 +++++++++++-------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/DDrawCompat/Gdi/PaintHandlers.cpp b/DDrawCompat/Gdi/PaintHandlers.cpp index cc8ff6d..e7e39a9 100644 --- a/DDrawCompat/Gdi/PaintHandlers.cpp +++ b/DDrawCompat/Gdi/PaintHandlers.cpp @@ -156,36 +156,24 @@ namespace LRESULT onEraseBackground(HWND hwnd, HDC dc, WNDPROC origWndProc) { - if (!hwnd || !Gdi::beginGdiRendering()) + if (hwnd && Gdi::beginGdiRendering()) { - return CallWindowProc(origWndProc, hwnd, WM_ERASEBKGND, reinterpret_cast(dc), 0); - } - - LRESULT result = 0; - HDC compatDc = Gdi::Dc::getDc(dc); - if (compatDc) - { - result = CallWindowProc(origWndProc, hwnd, WM_ERASEBKGND, reinterpret_cast(compatDc), 0); - Gdi::Dc::releaseDc(dc); - if (result) + LRESULT result = 0; + HDC compatDc = Gdi::Dc::getDc(dc); + if (compatDc) { - DDraw::RealPrimarySurface::disableUpdates(); + result = CallWindowProc(origWndProc, hwnd, WM_ERASEBKGND, reinterpret_cast(compatDc), 0); + Gdi::Dc::releaseDc(dc); + } + + Gdi::endGdiRendering(); + if (compatDc) + { + return result; } } - else - { - result = CallWindowProc(origWndProc, hwnd, WM_ERASEBKGND, reinterpret_cast(dc), 0); - } - Gdi::endGdiRendering(); - - if (result && compatDc) - { - UpdateWindow(hwnd); - DDraw::RealPrimarySurface::enableUpdates(); - } - - return result; + return CallWindowProc(origWndProc, hwnd, WM_ERASEBKGND, reinterpret_cast(dc), 0); } LRESULT onMenuPaint(HWND hwnd, WNDPROC origWndProc)