File Index Symbol Index

#include "WinNativeDpiAwareness.h"
#pragma comment(lib,
"Shcore.lib"
)
namespace
vl
{
namespace
presentation
{
namespace
windows
{
#define USE_API(NAME, API) static auto proc_##API = (decltype(&API))(GetProcAddress(GetModuleHandle(L#NAME), #API))
void
InitDpiAwareness
(
bool
dpiAware
) {
if
(
proc_SetProcessDpiAwarenessContext
) {
return
; }
if
(
proc_SetProcessDpiAwareness
) {
proc_SetProcessDpiAwareness
(
dpiAware
?
PROCESS_PER_MONITOR_DPI_AWARE
:
PROCESS_DPI_UNAWARE
);
return
; } }
void
DpiAwared_GetDpiForMonitor
(
HMONITOR
monitor
,
UINT
*
x
,
UINT
*
y
) {
if
(
proc_GetDpiForMonitor
) { {
return
; } } *
x
=
96
; *
y
=
96
; }
void
DpiAwared_GetDpiForWindow
(
HWND
handle
,
UINT
*
x
,
UINT
*
y
) {
if
(
proc_GetDpiForWindow
) { *
x
= *
y
=
proc_GetDpiForWindow
(
handle
); }
else
{ { *
x
= *
y
=
96
; }
else
{
DpiAwared_GetDpiForMonitor
(
monitor
,
x
,
y
); } } }
void
DpiAwared_AdjustWindowRect
(
LPRECT
rect
,
HWND
handle
,
UINT
dpi
) {
if
(
proc_AdjustWindowRectExForDpi
) { }
else
{ } }
int
DpiAwared_GetSystemMetrics
(
int
index
,
UINT
dpi
) {
if
(
proc_GetSystemMetricsForDpi
) {
return
proc_GetSystemMetricsForDpi
(
index
,
dpi
); }
else
{
return
GetSystemMetrics
(
index
); } }
#undef USE_API
} } }