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