From f2924eee05daff158573fe261a177af6b30302d8 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 30 Jan 2023 18:38:41 +0100 Subject: [PATCH] Early DPI awareness --- src/client/component/splash.cpp | 15 --------------- src/client/main.cpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/client/component/splash.cpp b/src/client/component/splash.cpp index d2010e80..b86f2f6d 100644 --- a/src/client/component/splash.cpp +++ b/src/client/component/splash.cpp @@ -25,19 +25,6 @@ namespace splash return utils::image::create_bitmap(img); } - void enable_dpi_awareness() - { - const utils::nt::library user32{"user32.dll"}; - const auto set_dpi = user32 - ? user32.get_proc( - "SetProcessDpiAwarenessContext") - : nullptr; - if (set_dpi) - { - set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); - } - } - void destroy_window() { if (window && IsWindow(window)) @@ -169,8 +156,6 @@ namespace splash { component() { - enable_dpi_awareness(); - image = load_splash_image(); window_thread = std::thread([this] { diff --git a/src/client/main.cpp b/src/client/main.cpp index 6e5e30a1..805bd8ff 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -170,6 +170,19 @@ namespace return true; } + void enable_dpi_awareness() + { + const utils::nt::library user32{ "user32.dll" }; + const auto set_dpi = user32 + ? user32.get_proc( + "SetProcessDpiAwarenessContext") + : nullptr; + if (set_dpi) + { + set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } + } + int main() { if (handle_process_runner()) @@ -180,6 +193,8 @@ namespace FARPROC entry_point{}; srand(uint32_t(time(nullptr)) ^ ~(GetTickCount() * GetCurrentProcessId())); + enable_dpi_awareness(); + { auto premature_shutdown = true; const auto _ = utils::finally([&premature_shutdown]