Update window.cpp

This commit is contained in:
Maurice Heumann 2023-04-11 08:21:06 +02:00 committed by GitHub
parent cc975a74de
commit d973dba010

View File

@ -1,6 +1,8 @@
#include <std_include.hpp>
#include "window.hpp"
#include <utils/nt.hpp>
#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<UINT(WINAPI *)(HWND)>("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;