1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#pragma once
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
#ifdef __cplusplus
extern "C" {
#endif
// from WinUser.h
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
#ifndef USER_DEFAULT_SCREEN_DPI
#define USER_DEFAULT_SCREEN_DPI 96
#endif
typedef enum DPIU_AWARENESS
{
DPIU_AWARENESS_NONE = 0x0,
DPIU_AWARENESS_SYSTEM = 0x1,
DPIU_AWARENESS_PERMONITOR = 0x2,
DPIU_AWARENESS_PERMONITORV2 = 0x4,
DPIU_AWARENESS_GDISCALED = 0x8,
} DPIU_PROCESS_AWARENESS;
typedef struct _DPIU_MONITOR_CONTEXT
{
UINT nDpi;
MONITORINFOEXW mi;
} DPIU_MONITOR_CONTEXT;
typedef struct _DPIU_WINDOW_CONTEXT
{
UINT nDpi;
} DPIU_WINDOW_CONTEXT;
typedef BOOL (APIENTRY* PFN_ADJUSTWINDOWRECTEXFORDPI)(
__in LPRECT lpRect,
__in DWORD dwStyle,
__in BOOL bMenu,
__in DWORD dwExStyle,
__in UINT dpi
);
typedef UINT (APIENTRY *PFN_GETDPIFORWINDOW)(
__in HWND hwnd
);
typedef BOOL (APIENTRY* PFN_SETPROCESSDPIAWARE)();
typedef BOOL (APIENTRY* PFN_SETPROCESSDPIAWARENESSCONTEXT)(
__in DPI_AWARENESS_CONTEXT value
);
#ifdef DPI_ENUMS_DECLARED
typedef HRESULT(APIENTRY* PFN_GETDPIFORMONITOR)(
__in HMONITOR hmonitor,
__in MONITOR_DPI_TYPE dpiType,
__in UINT* dpiX,
__in UINT* dpiY
);
typedef HRESULT(APIENTRY* PFN_SETPROCESSDPIAWARENESS)(
__in PROCESS_DPI_AWARENESS value
);
#endif
void DAPI DpiuInitialize();
void DAPI DpiuUninitialize();
/********************************************************************
DpiuAdjustWindowRect - calculate the required size of the window rectangle,
based on the desired size of the client rectangle
and the provided DPI.
*******************************************************************/
void DAPI DpiuAdjustWindowRect(
__in RECT* pWindowRect,
__in DWORD dwStyle,
__in BOOL fMenu,
__in DWORD dwExStyle,
__in UINT nDpi
);
/********************************************************************
DpiuGetMonitorContextFromPoint - get the DPI context of the monitor from the given point.
*******************************************************************/
HRESULT DAPI DpiuGetMonitorContextFromPoint(
__in const POINT* pt,
__out DPIU_MONITOR_CONTEXT** ppMonitorContext
);
/********************************************************************
DpiuGetWindowContext - get the DPI context of the given window.
*******************************************************************/
void DAPI DpiuGetWindowContext(
__in HWND hWnd,
__in DPIU_WINDOW_CONTEXT* pWindowContext
);
/********************************************************************
DpiuScaleValue - scale the value to the target DPI.
*******************************************************************/
int DAPI DpiuScaleValue(
__in int nDefaultDpiValue,
__in UINT nTargetDpi
);
/********************************************************************
DpiuSetProcessDpiAwareness - set the process DPI awareness. The ranking is
PERMONITORV2 > PERMONITOR > SYSTEM > GDISCALED > NONE.
*******************************************************************/
HRESULT DAPI DpiuSetProcessDpiAwareness(
__in DPIU_AWARENESS supportedAwareness,
__in_opt DPIU_AWARENESS* pSelectedAwareness
);
#ifdef __cplusplus
}
#endif
|