From 2a23cf56368c1e63dd48c7300569bfb80c473084 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 17 Jan 2016 14:47:47 +0100 Subject: [PATCH] Added files missing from 2 commits earlier Some new files were accidentally left out of a previous commit: "Revamping GDI interworking - Part 2" 1999d1c56ef4af2b173764a0dffff0c270357628 The missing files are now added. --- DDrawCompat/CompatGdiCaret.h | 6 ++++ DDrawCompat/CompatGdiWinProc.cpp | 61 ++++++++++++++++++++++++++++++++ DDrawCompat/CompatGdiWinProc.h | 6 ++++ 3 files changed, 73 insertions(+) create mode 100644 DDrawCompat/CompatGdiCaret.h create mode 100644 DDrawCompat/CompatGdiWinProc.cpp create mode 100644 DDrawCompat/CompatGdiWinProc.h diff --git a/DDrawCompat/CompatGdiCaret.h b/DDrawCompat/CompatGdiCaret.h new file mode 100644 index 0000000..8346199 --- /dev/null +++ b/DDrawCompat/CompatGdiCaret.h @@ -0,0 +1,6 @@ +#pragma once + +namespace CompatGdiCaret +{ + void installHooks(); +} diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/CompatGdiWinProc.cpp new file mode 100644 index 0000000..a5af382 --- /dev/null +++ b/DDrawCompat/CompatGdiWinProc.cpp @@ -0,0 +1,61 @@ +#define WIN32_LEAN_AND_MEAN + +#include + +#include "CompatGdi.h" +#include "CompatGdiDc.h" +#include "CompatGdiWinProc.h" +#include "DDrawLog.h" + +namespace +{ + void eraseBackground(HWND hwnd, HDC dc); + + LRESULT CALLBACK callWndRetProc(int nCode, WPARAM wParam, LPARAM lParam) + { + if (HC_ACTION == nCode) + { + auto ret = reinterpret_cast(lParam); + if (WM_ERASEBKGND == ret->message) + { + if (0 != ret->lResult) + { + eraseBackground(ret->hwnd, reinterpret_cast(ret->wParam)); + } + } + else if (WM_WINDOWPOSCHANGED == ret->message) + { + CompatGdi::invalidate(); + } + else if (WM_VSCROLL == ret->message || WM_HSCROLL == ret->message) + { + InvalidateRect(ret->hwnd, nullptr, TRUE); + } + } + + return CallNextHookEx(nullptr, nCode, wParam, lParam); + } + + void eraseBackground(HWND hwnd, HDC dc) + { + if (CompatGdi::beginGdiRendering()) + { + HDC compatDc = CompatGdiDc::getDc(dc); + if (compatDc) + { + SendMessage(hwnd, WM_ERASEBKGND, reinterpret_cast(compatDc), 0); + CompatGdiDc::releaseDc(dc); + } + CompatGdi::endGdiRendering(); + } + } +} + +namespace CompatGdiWinProc +{ + void installHooks() + { + const DWORD threadId = GetCurrentThreadId(); + SetWindowsHookEx(WH_CALLWNDPROCRET, callWndRetProc, nullptr, threadId); + } +} diff --git a/DDrawCompat/CompatGdiWinProc.h b/DDrawCompat/CompatGdiWinProc.h new file mode 100644 index 0000000..a291106 --- /dev/null +++ b/DDrawCompat/CompatGdiWinProc.h @@ -0,0 +1,6 @@ +#pragma once + +namespace CompatGdiWinProc +{ + void installHooks(); +}