From 6f14ddf9ae79f5870718d453dbb6dfa1a61737b2 Mon Sep 17 00:00:00 2001 From: narzoul Date: Tue, 31 Dec 2019 11:40:27 +0100 Subject: [PATCH] Fixed menu bar highlighting when window is not in top-left corner of desktop --- DDrawCompat/Gdi/DcFunctions.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/DDrawCompat/Gdi/DcFunctions.cpp b/DDrawCompat/Gdi/DcFunctions.cpp index d710575..89004cf 100644 --- a/DDrawCompat/Gdi/DcFunctions.cpp +++ b/DDrawCompat/Gdi/DcFunctions.cpp @@ -82,6 +82,16 @@ namespace return hasDisplayDcArg(t) || hasDisplayDcArg(params...); } + bool lpToScreen(HWND hwnd, HDC dc, POINT& p) + { + LPtoDP(dc, &p, 1); + RECT wr = {}; + GetWindowRect(hwnd, &wr); + p.x += wr.left; + p.y += wr.top; + return true; + } + template T replaceDc(T t) { @@ -129,7 +139,7 @@ namespace RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE); } else if (GetCurrentThreadId() == GetWindowThreadProcessId(hwnd, nullptr) && - LPtoDP(hdc, &p, 1) && + lpToScreen(hwnd, hdc, p) && HTMENU == SendMessage(hwnd, WM_NCHITTEST, 0, (p.y << 16) | (p.x & 0xFFFF))) { WINDOWINFO wi = {};