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

Fixed WM_SETTEXT drawing over previous caption text

This commit is contained in:
narzoul 2020-11-28 12:48:36 +01:00
parent 29f311ddc7
commit 12944404e8
2 changed files with 32 additions and 4 deletions

View File

@ -46,6 +46,7 @@ namespace
LRESULT onNcPaint(HWND hwnd, WPARAM wParam, WNDPROC origWndProc);
LRESULT onPaint(HWND hwnd, WNDPROC origWndProc);
LRESULT onPrint(HWND hwnd, UINT msg, HDC dc, LONG flags, WNDPROC origWndProc);
LRESULT onSetText(HWND hwnd, WPARAM wParam, LPARAM lParam, WNDPROC origWndProc);
User32WndProc* g_currentUser32WndProc = nullptr;
std::vector<std::string> g_failedHooks;
@ -148,6 +149,9 @@ namespace
case WM_PRINTCLIENT:
return onPrint(hwnd, msg, reinterpret_cast<HDC>(wParam), lParam, origWndProc);
case WM_SETTEXT:
return onSetText(hwnd, wParam, lParam, origWndProc);
default:
return CallWindowProc(origWndProc, hwnd, msg, wParam, lParam);
}
@ -389,6 +393,30 @@ namespace
return result;
}
LRESULT onSetText(HWND hwnd, WPARAM wParam, LPARAM lParam, WNDPROC origWndProc)
{
LRESULT result = CallWindowProc(origWndProc, hwnd, WM_SETTEXT, wParam, lParam);
if (0 == result ||
0 == (CALL_ORIG_FUNC(GetWindowLongA)(hwnd, GWL_STYLE) & WS_CAPTION))
{
return result;
}
HDC windowDc = GetWindowDC(hwnd);
HDC compatDc = Gdi::Dc::getDc(windowDc);
if (compatDc)
{
Gdi::AccessGuard accessGuard(Gdi::ACCESS_WRITE);
Gdi::TitleBar titleBar(hwnd, compatDc);
titleBar.drawCaption();
Gdi::Dc::releaseDc(windowDc);
}
CALL_ORIG_FUNC(ReleaseDC)(hwnd, windowDc);
return result;
}
LRESULT scrollBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, WNDPROC origWndProc)
{
switch (msg)

View File

@ -676,9 +676,9 @@ namespace Compat
#define LOG_PARAM_CASE_2(param, msg, TypeA, TypeW) \
case msg: \
if (IsWindowUnicode(wm.hwnd)) \
os << reinterpret_cast<const TypeW>(param); \
os << *reinterpret_cast<const TypeW*>(&param); \
else \
os << reinterpret_cast<const TypeA>(param); \
os << *reinterpret_cast<const TypeA*>(&param); \
break;
#define LOG_WPARAM_CASE_1(msg, ...) LOG_PARAM_CASE_1(wm.wParam, msg, __VA_ARGS__)
@ -798,7 +798,7 @@ namespace Compat
switch (wm.msg.msg)
{
LOG_LPARAM_CASE_1(WM_ACTIVATE, HWND);
LOG_LPARAM_CASE_2(WM_ASKCBFORMATNAME, LPCSTR, LPCWSTR);
LOG_LPARAM_CASE_2(WM_ASKCBFORMATNAME, Compat::detail::Out<LPCSTR>, Compat::detail::Out<LPCWSTR>);
LOG_LPARAM_CASE_1(WM_CAPTURECHANGED, HWND);
LOG_LPARAM_CASE_1(WM_CHANGECBCHAIN, HWND);
LOG_LPARAM_CASE_1(WM_CHARTOITEM, HWND);
@ -826,7 +826,7 @@ namespace Compat
LOG_LPARAM_CASE_1(WM_GETDPISCALEDSIZE, SIZE*);
LOG_LPARAM_CASE_1(WM_GETICON, DWORD);
LOG_LPARAM_CASE_1(WM_GETMINMAXINFO, MINMAXINFO*);
LOG_LPARAM_CASE_2(WM_GETTEXT, LPCSTR, LPCWSTR);
LOG_LPARAM_CASE_2(WM_GETTEXT, Compat::detail::Out<LPCSTR>, Compat::detail::Out<LPCWSTR>);
LOG_LPARAM_CASE_1(WM_HELP, HELPINFO*);
LOG_LPARAM_CASE_1(WM_HOTKEY, std::pair<Compat::detail::Hex<WORD>, Compat::detail::Hex<WORD>>);
LOG_LPARAM_CASE_1(WM_HSCROLL, HWND);