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

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.
This commit is contained in:
narzoul 2016-01-17 14:47:47 +01:00
parent 1883d919da
commit 2a23cf5636
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,6 @@
#pragma once
namespace CompatGdiCaret
{
void installHooks();
}

View File

@ -0,0 +1,61 @@
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#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<CWPRETSTRUCT*>(lParam);
if (WM_ERASEBKGND == ret->message)
{
if (0 != ret->lResult)
{
eraseBackground(ret->hwnd, reinterpret_cast<HDC>(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<WPARAM>(compatDc), 0);
CompatGdiDc::releaseDc(dc);
}
CompatGdi::endGdiRendering();
}
}
}
namespace CompatGdiWinProc
{
void installHooks()
{
const DWORD threadId = GetCurrentThreadId();
SetWindowsHookEx(WH_CALLWNDPROCRET, callWndRetProc, nullptr, threadId);
}
}

View File

@ -0,0 +1,6 @@
#pragma once
namespace CompatGdiWinProc
{
void installHooks();
}