From acd61bbed3d14c445fef0dc6245277b10f690481 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sat, 23 Jan 2016 23:36:01 +0100 Subject: [PATCH] Disabled DWM transitions and nonclient area rendering Disabling DWM nonclient area rendering restores proper hit testing for the non-themed caption buttons. Transitions are disabled just in case. --- DDrawCompat/CompatGdiWinProc.cpp | 19 ++++++++++++++++++- DDrawCompat/DDrawCompat.vcxproj | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/CompatGdiWinProc.cpp index 025a1df..3edfec8 100644 --- a/DDrawCompat/CompatGdiWinProc.cpp +++ b/DDrawCompat/CompatGdiWinProc.cpp @@ -1,5 +1,6 @@ #define WIN32_LEAN_AND_MEAN +#include #include #include "CompatGdi.h" @@ -9,6 +10,7 @@ namespace { + void disableDwmAttributes(HWND hwnd); void eraseBackground(HWND hwnd, HDC dc); bool isScrollBarVisible(HWND hwnd, LONG windowStyles, LONG sbStyle, LONG sbObjectId); void ncPaint(HWND hwnd); @@ -19,7 +21,11 @@ namespace if (HC_ACTION == nCode) { auto ret = reinterpret_cast(lParam); - if (WM_ERASEBKGND == ret->message) + if (WM_CREATE == ret->message) + { + disableDwmAttributes(ret->hwnd); + } + else if (WM_ERASEBKGND == ret->message) { if (0 != ret->lResult) { @@ -46,6 +52,17 @@ namespace return CallNextHookEx(nullptr, nCode, wParam, lParam); } + void disableDwmAttributes(HWND hwnd) + { + DWMNCRENDERINGPOLICY ncRenderingPolicy = DWMNCRP_DISABLED; + DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, + &ncRenderingPolicy, sizeof(ncRenderingPolicy)); + + BOOL disableTransitions = TRUE; + DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, + &disableTransitions, sizeof(disableTransitions)); + } + void drawSizeBox(HWND hwnd, HDC compatDc, const RECT& windowRect, const RECT& clientRect) { LONG style = GetWindowLongPtr(hwnd, GWL_STYLE); diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 6b161bd..fa6ae48 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -94,7 +94,7 @@ DDrawCompat.def - dxguid.lib;detours.lib;msimg32.lib;oleacc.lib;uxtheme.lib;%(AdditionalDependencies) + dxguid.lib;detours.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;%(AdditionalDependencies) @@ -121,7 +121,7 @@ DDrawCompat.def - dxguid.lib;detours.lib;msimg32.lib;oleacc.lib;uxtheme.lib;%(AdditionalDependencies) + dxguid.lib;detours.lib;msimg32.lib;oleacc.lib;uxtheme.lib;dwmapi.lib;%(AdditionalDependencies) No