diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-06 19:22:37 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-07-06 21:30:49 +1000 |
| commit | 219964095a1f4678d8c8e7ae2685c52392161ca2 (patch) | |
| tree | 2eff04c6a6bfebbc05b667a3bd1fa5ebf04edf6d /src/dutil/dpiutil.cpp | |
| parent | abeba64d77336b3fbf9aafe9ecc66b779c1e5d02 (diff) | |
| download | wix-219964095a1f4678d8c8e7ae2685c52392161ca2.tar.gz wix-219964095a1f4678d8c8e7ae2685c52392161ca2.tar.bz2 wix-219964095a1f4678d8c8e7ae2685c52392161ca2.zip | |
WIXFEAT:4906 Make Window's Height and Width refer to its client area.
Diffstat (limited to 'src/dutil/dpiutil.cpp')
| -rw-r--r-- | src/dutil/dpiutil.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/dutil/dpiutil.cpp b/src/dutil/dpiutil.cpp index a27ee8c5..02a9580c 100644 --- a/src/dutil/dpiutil.cpp +++ b/src/dutil/dpiutil.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #define DpiuExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_DPIUTIL, p, x, s, __VA_ARGS__) | 15 | #define DpiuExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_DPIUTIL, p, x, s, __VA_ARGS__) |
| 16 | #define DpiuExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_DPIUTIL, e, x, s, __VA_ARGS__) | 16 | #define DpiuExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_DPIUTIL, e, x, s, __VA_ARGS__) |
| 17 | 17 | ||
| 18 | static PFN_ADJUSTWINDOWRECTEXFORDPI vpfnAdjustWindowRectExForDpi = NULL; | ||
| 18 | static PFN_GETDPIFORMONITOR vpfnGetDpiForMonitor = NULL; | 19 | static PFN_GETDPIFORMONITOR vpfnGetDpiForMonitor = NULL; |
| 19 | static PFN_GETDPIFORWINDOW vpfnGetDpiForWindow = NULL; | 20 | static PFN_GETDPIFORWINDOW vpfnGetDpiForWindow = NULL; |
| 20 | 21 | ||
| @@ -37,6 +38,7 @@ DAPI_(void) DpiuInitialize() | |||
| 37 | if (SUCCEEDED(hr)) | 38 | if (SUCCEEDED(hr)) |
| 38 | { | 39 | { |
| 39 | // Ignore failures. | 40 | // Ignore failures. |
| 41 | vpfnAdjustWindowRectExForDpi = reinterpret_cast<PFN_ADJUSTWINDOWRECTEXFORDPI>(::GetProcAddress(vhUser32Dll, "AdjustWindowRectExForDpi")); | ||
| 40 | vpfnGetDpiForWindow = reinterpret_cast<PFN_GETDPIFORWINDOW>(::GetProcAddress(vhUser32Dll, "GetDpiForWindow")); | 42 | vpfnGetDpiForWindow = reinterpret_cast<PFN_GETDPIFORWINDOW>(::GetProcAddress(vhUser32Dll, "GetDpiForWindow")); |
| 41 | } | 43 | } |
| 42 | 44 | ||
| @@ -57,11 +59,35 @@ DAPI_(void) DpiuUninitialize() | |||
| 57 | 59 | ||
| 58 | vhShcoreDll = NULL; | 60 | vhShcoreDll = NULL; |
| 59 | vhUser32Dll = NULL; | 61 | vhUser32Dll = NULL; |
| 62 | vpfnAdjustWindowRectExForDpi = NULL; | ||
| 60 | vpfnGetDpiForMonitor = NULL; | 63 | vpfnGetDpiForMonitor = NULL; |
| 61 | vpfnGetDpiForWindow = NULL; | 64 | vpfnGetDpiForWindow = NULL; |
| 62 | vfDpiuInitialized = FALSE; | 65 | vfDpiuInitialized = FALSE; |
| 63 | } | 66 | } |
| 64 | 67 | ||
| 68 | DAPI_(void) DpiuAdjustWindowRect( | ||
| 69 | __in RECT* pWindowRect, | ||
| 70 | __in DWORD dwStyle, | ||
| 71 | __in BOOL fMenu, | ||
| 72 | __in DWORD dwExStyle, | ||
| 73 | __in UINT nDpi | ||
| 74 | ) | ||
| 75 | { | ||
| 76 | if (WS_SYSMENU & dwStyle) | ||
| 77 | { | ||
| 78 | dwStyle |= WS_CAPTION; // WS_CAPTION is required with WS_SYSMENU, AdjustWindowRect* won't work properly when it's not specified. | ||
| 79 | } | ||
| 80 | |||
| 81 | if (vpfnAdjustWindowRectExForDpi) | ||
| 82 | { | ||
| 83 | vpfnAdjustWindowRectExForDpi(pWindowRect, dwStyle, fMenu, dwExStyle, nDpi); | ||
| 84 | } | ||
| 85 | else | ||
| 86 | { | ||
| 87 | ::AdjustWindowRectEx(pWindowRect, dwStyle, fMenu, dwExStyle); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 65 | DAPI_(HRESULT) DpiuGetMonitorContextFromPoint( | 91 | DAPI_(HRESULT) DpiuGetMonitorContextFromPoint( |
| 66 | __in const POINT* pt, | 92 | __in const POINT* pt, |
| 67 | __out DPIU_MONITOR_CONTEXT** ppMonitorContext | 93 | __out DPIU_MONITOR_CONTEXT** ppMonitorContext |
