terminal/src/interactivity/win32/windowdpiapi.hpp
Dustin Howett 1e42bc8e4f Merged PR 5421982: Reflect OS build changes
[Git2Git] Git Train: Merge of building/rs_onecore_dep_uxp/201117-2002 into official/rs_onecore_dep_uxp Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_onecore_dep_uxp 526043ab6050397506b3cdb77e6a43b5ca9a2e9a

Related work items: MSFT-29990377
2020-11-19 23:21:37 +00:00

76 lines
2.2 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- windowdpiapi.hpp
Abstract:
- This module is used for abstracting calls to High DPI APIs.
Author(s):
- Michael Niksa (MiNiksa) Apr-2016
--*/
#pragma once
#include "..\inc\IHighDpiApi.hpp"
// Uncomment to build ConFans or other down-level build scenarios.
// #define CON_DPIAPI_INDIRECT
// To avoid a break when the RS1 SDK gets dropped in, don't redef.
#ifndef _DPI_AWARENESS_CONTEXTS_
DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
typedef enum DPI_AWARENESS
{
DPI_AWARENESS_INVALID = -1,
DPI_AWARENESS_UNAWARE = 0,
DPI_AWARENESS_SYSTEM_AWARE = 1,
DPI_AWARENESS_PER_MONITOR_AWARE = 2
} DPI_AWARENESS;
#define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1)
#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2)
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3)
#endif
// This type is being defined in RS2 but is percolating through the
// tree. Def it here if it hasn't collided with our branch yet.
#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4)
#endif
namespace Microsoft::Console::Interactivity::Win32
{
class WindowDpiApi final : public IHighDpiApi
{
public:
// IHighDpi Interface
BOOL SetProcessDpiAwarenessContext();
[[nodiscard]] HRESULT SetProcessPerMonitorDpiAwareness();
// Module-internal Functions
BOOL SetProcessDpiAwarenessContext(_In_ DPI_AWARENESS_CONTEXT dpiContext);
BOOL AdjustWindowRectExForDpi(_Inout_ LPRECT const lpRect,
const DWORD dwStyle,
const BOOL bMenu,
const DWORD dwExStyle,
const UINT dpi);
int GetDpiForWindow(const HWND hwnd);
int GetSystemMetricsForDpi(const int nIndex,
const UINT dpi);
#ifdef CON_DPIAPI_INDIRECT
WindowDpiApi();
#endif
~WindowDpiApi();
private:
HMODULE _hUser32;
};
}