Better DPI awareness
This commit is contained in:
parent
924e476328
commit
c25ad4dcb8
@ -174,13 +174,41 @@ namespace
|
||||
void enable_dpi_awareness()
|
||||
{
|
||||
const utils::nt::library user32{"user32.dll"};
|
||||
const auto set_dpi = user32
|
||||
? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>(
|
||||
"SetProcessDpiAwarenessContext")
|
||||
: nullptr;
|
||||
if (set_dpi)
|
||||
|
||||
{
|
||||
set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
const auto set_dpi = user32
|
||||
? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>(
|
||||
"SetProcessDpiAwarenessContext")
|
||||
: nullptr;
|
||||
if (set_dpi)
|
||||
{
|
||||
set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const utils::nt::library shcore{"shcore.dll"};
|
||||
const auto set_dpi = shcore
|
||||
? shcore.get_proc<HRESULT(WINAPI*)(PROCESS_DPI_AWARENESS)>(
|
||||
"SetProcessDpiAwareness")
|
||||
: nullptr;
|
||||
if (set_dpi)
|
||||
{
|
||||
set_dpi(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const auto set_dpi = user32
|
||||
? user32.get_proc<BOOL(WINAPI*)()>(
|
||||
"SetProcessDPIAware")
|
||||
: nullptr;
|
||||
if (set_dpi)
|
||||
{
|
||||
set_dpi();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <atlsafe.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <wincrypt.h>
|
||||
#include <shellscalingapi.h>
|
||||
|
||||
// min and max is required by gdi, therefore NOMINMAX won't work
|
||||
#ifdef max
|
||||
|
Loading…
Reference in New Issue
Block a user