diff --git a/src/client/launcher/window.cpp b/src/client/launcher/window.cpp index 75564319..b9c36563 100644 --- a/src/client/launcher/window.cpp +++ b/src/client/launcher/window.cpp @@ -1,6 +1,8 @@ #include #include "window.hpp" +#include + #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif @@ -8,6 +10,19 @@ namespace { thread_local uint32_t window_count = 0; + + uint32_t get_dpi_for_window(const HWND window) + { + const utils::nt::library user32{"user32.dll"}; + const auto get_dpi = user32 ? user32.get_proc("GetDpiForWindow") : nullptr; + + if (!get_dpi) + { + return USER_DEFAULT_SCREEN_DPI; + } + + return get_dpi(window); + } } window::window(const std::string& title, const int width, const int height, @@ -75,7 +90,7 @@ LRESULT window::processor(const UINT message, const WPARAM w_param, const LPARAM { if (message == WM_DPICHANGED) { - const auto dpi = GetDpiForWindow(*this); + const auto dpi = get_dpi_for_window(*this); if (dpi != this->last_dpi_) { RECT rect;