forked from stuerp/foo_vis_spectrum_analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupport.cpp
More file actions
37 lines (26 loc) · 825 Bytes
/
Support.cpp
File metadata and controls
37 lines (26 loc) · 825 Bytes
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
/** $VER: Support.cpp (2024.03.09) P. Stuer **/
#include "framework.h"
#include "Support.h"
#include "Direct2D.h"
#include "SafeModuleHandle.h"
#pragma hdrstop
/// <summary>
/// Gets the DPI setting of the specified window.
/// </summary>
HRESULT GetDPI(HWND hWnd, UINT & dpi)
{
SafeModuleHandle Module = SafeModuleHandle(L"user32.dll");
typedef UINT (WINAPI * GetDpiForWindow_t)(_In_ HWND hwnd);
GetDpiForWindow_t GetDpiForWindow_ = (GetDpiForWindow_t) Module.GetFunctionAddress("GetDpiForWindow");
if (GetDpiForWindow_ != nullptr)
dpi = GetDpiForWindow_(hWnd);
else
{
FLOAT DPIX, DPIY;
#pragma warning(disable: 4996)
_Direct2D.Factory->GetDesktopDpi(&DPIX, &DPIY);
#pragma warning(default: 4996)
dpi = (UINT) DPIX;
}
return S_OK;
}