diff --git a/libraries/ZWidget/src/window/win32/win32window.cpp b/libraries/ZWidget/src/window/win32/win32window.cpp index 8a1fda50c0..64d4701ed5 100644 --- a/libraries/ZWidget/src/window/win32/win32window.cpp +++ b/libraries/ZWidget/src/window/win32/win32window.cpp @@ -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(GetProcAddress(hMod, "GetDpiForWindow")); + } + + if (pGetDpiForWindow) + return pGetDpiForWindow(WindowHandle) / 96.0; + else + return 1.0; } std::string Win32Window::GetClipboardText()