From cfd3567a8a1ec0f907f90763a637b691a2ac4a98 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Thu, 16 Feb 2023 21:50:15 +0900 Subject: [PATCH] Enable dark mode window title bar if applicable --- Dalamud.Boot/pch.h | 1 + Dalamud.Boot/xivfixes.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Dalamud.Boot/pch.h b/Dalamud.Boot/pch.h index 2e11e0ab7..3302a44fb 100644 --- a/Dalamud.Boot/pch.h +++ b/Dalamud.Boot/pch.h @@ -16,6 +16,7 @@ // Windows Header Files (2) #include +#include #include #include #include diff --git a/Dalamud.Boot/xivfixes.cpp b/Dalamud.Boot/xivfixes.cpp index bfbca7d8a..00fc2a008 100644 --- a/Dalamud.Boot/xivfixes.cpp +++ b/Dalamud.Boot/xivfixes.cpp @@ -201,6 +201,17 @@ void xivfixes::prevent_devicechange_crashes(bool bApply) { if (uMsg == WM_SIZE && wParam == SIZE_RESTORED && (GetWindowLongW(hWnd, GWL_STYLE) & WS_POPUP)) return ShowWindow(hWnd, SW_MAXIMIZE); + if (uMsg == WM_CREATE) { + // While at it, also apply dark mode title bar to the game. + if (const auto dwmapi = LoadLibraryW(L"dwmapi.dll")) { + if (const auto fn = reinterpret_cast(GetProcAddress(dwmapi, "DwmSetWindowAttribute"))) { + const BOOL trueValue = TRUE; + fn(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &trueValue, sizeof trueValue); + } + FreeLibrary(dwmapi); + } + } + return s_pfnGameWndProc(hWnd, uMsg, wParam, lParam); });