From d8a8fee67e5341478dea6c6478125b1394cf17d2 Mon Sep 17 00:00:00 2001 From: Vlad Loktionov Date: Sat, 8 Apr 2023 00:35:41 +0300 Subject: [PATCH] Make launcher window use dark mode --- src/client/launcher/window.cpp | 8 ++++++++ src/client/launcher/window.hpp | 1 + src/client/std_include.hpp | 1 + 3 files changed, 10 insertions(+) diff --git a/src/client/launcher/window.cpp b/src/client/launcher/window.cpp index 1b6dc4a7..75564319 100644 --- a/src/client/launcher/window.cpp +++ b/src/client/launcher/window.cpp @@ -1,6 +1,10 @@ #include #include "window.hpp" +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + namespace { thread_local uint32_t window_count = 0; @@ -34,6 +38,10 @@ window::window(const std::string& title, const int width, const int height, this->handle_ = CreateWindowExA(NULL, this->wc_.lpszClassName, title.data(), flags, x, y, width, height, nullptr, nullptr, this->wc_.hInstance, this); + BOOL value = TRUE; + DwmSetWindowAttribute(this->handle_, + DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value)); + SendMessageA(this->handle_, WM_DPICHANGED, 0, 0); ShowWindow(this->handle_, SW_SHOW); SetForegroundWindow(this->handle_); diff --git a/src/client/launcher/window.hpp b/src/client/launcher/window.hpp index 9b840759..17808c4e 100644 --- a/src/client/launcher/window.hpp +++ b/src/client/launcher/window.hpp @@ -1,4 +1,5 @@ #pragma once +#pragma comment (lib, "dwmapi.lib") class window { diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index e64b1b8c..59b83a41 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include