Update window.cpp
This commit is contained in:
parent
cc975a74de
commit
d973dba010
@ -1,6 +1,8 @@
|
|||||||
#include <std_include.hpp>
|
#include <std_include.hpp>
|
||||||
#include "window.hpp"
|
#include "window.hpp"
|
||||||
|
|
||||||
|
#include <utils/nt.hpp>
|
||||||
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||||
#endif
|
#endif
|
||||||
@ -8,6 +10,19 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
thread_local uint32_t window_count = 0;
|
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,
|
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)
|
if (message == WM_DPICHANGED)
|
||||||
{
|
{
|
||||||
const auto dpi = GetDpiForWindow(*this);
|
const auto dpi = get_dpi_for_window(*this);
|
||||||
if (dpi != this->last_dpi_)
|
if (dpi != this->last_dpi_)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
Loading…
Reference in New Issue
Block a user