aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/inc/dpiutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/dpiutil.h')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/dpiutil.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/dpiutil.h b/src/libs/dutil/WixToolset.DUtil/inc/dpiutil.h
new file mode 100644
index 00000000..b30e2332
--- /dev/null
+++ b/src/libs/dutil/WixToolset.DUtil/inc/dpiutil.h
@@ -0,0 +1,120 @@
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
6extern "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
17typedef 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
26typedef struct _DPIU_MONITOR_CONTEXT
27{
28 UINT nDpi;
29 MONITORINFOEXW mi;
30} DPIU_MONITOR_CONTEXT;
31
32typedef struct _DPIU_WINDOW_CONTEXT
33{
34 UINT nDpi;
35} DPIU_WINDOW_CONTEXT;
36
37typedef 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 );
44typedef UINT (APIENTRY *PFN_GETDPIFORWINDOW)(
45 __in HWND hwnd
46 );
47typedef BOOL (APIENTRY* PFN_SETPROCESSDPIAWARE)();
48typedef BOOL (APIENTRY* PFN_SETPROCESSDPIAWARENESSCONTEXT)(
49 __in DPI_AWARENESS_CONTEXT value
50 );
51
52#ifdef DPI_ENUMS_DECLARED
53typedef HRESULT(APIENTRY* PFN_GETDPIFORMONITOR)(
54 __in HMONITOR hmonitor,
55 __in MONITOR_DPI_TYPE dpiType,
56 __in UINT* dpiX,
57 __in UINT* dpiY
58 );
59typedef HRESULT(APIENTRY* PFN_SETPROCESSDPIAWARENESS)(
60 __in PROCESS_DPI_AWARENESS value
61 );
62#endif
63
64void DAPI DpiuInitialize();
65void 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*******************************************************************/
73void 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*******************************************************************/
85HRESULT 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*******************************************************************/
94void 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*******************************************************************/
103int 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*******************************************************************/
113HRESULT DAPI DpiuSetProcessDpiAwareness(
114 __in DPIU_AWARENESS supportedAwareness,
115 __in_opt DPIU_AWARENESS* pSelectedAwareness
116 );
117
118#ifdef __cplusplus
119}
120#endif