Skip to content

Commit

Permalink
- dynamically import GetDpiForWindow from USER32.dll, else return a d…
Browse files Browse the repository at this point in the history
…efault value
  • Loading branch information
madame-rachelle authored and coelckers committed Apr 21, 2024
1 parent 1fe6556 commit 744e67e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libraries/ZWidget/src/window/win32/win32window.cpp
Expand Up @@ -271,9 +271,20 @@ int Win32Window::GetPixelHeight() const
return box.bottom;
}

typedef UINT(WINAPI* GetDpiForWindow_t)(HWND);
double Win32Window::GetDpiScale() const
{
return GetDpiForWindow(WindowHandle) / 96.0;
static GetDpiForWindow_t pGetDpiForWindow = nullptr;
if (!pGetDpiForWindow)
{
HMODULE hMod = LoadLibrary(TEXT("User32.dll"));
pGetDpiForWindow = reinterpret_cast<GetDpiForWindow_t>(GetProcAddress(hMod, "GetDpiForWindow"));
}

if (pGetDpiForWindow)
return pGetDpiForWindow(WindowHandle) / 96.0;
else
return 1.0;
}

std::string Win32Window::GetClipboardText()
Expand Down

0 comments on commit 744e67e

Please sign in to comment.