Skip to content

Commit

Permalink
optimized last commit to not retrieve the function repeatedly if it h…
Browse files Browse the repository at this point in the history
…as already failed.
  • Loading branch information
coelckers authored and madame-rachelle committed Apr 21, 2024
1 parent 51b3e4b commit 260c019
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libraries/ZWidget/src/window/win32/win32window.cpp
Expand Up @@ -275,10 +275,12 @@ typedef UINT(WINAPI* GetDpiForWindow_t)(HWND);
double Win32Window::GetDpiScale() const
{
static GetDpiForWindow_t pGetDpiForWindow = nullptr;
if (!pGetDpiForWindow)
static bool done = false;
if (!done)
{
HMODULE hMod = LoadLibrary(TEXT("User32.dll"));
pGetDpiForWindow = reinterpret_cast<GetDpiForWindow_t>(GetProcAddress(hMod, "GetDpiForWindow"));
HMODULE hMod = GetModuleHandleA("User32.dll");
if (hMod != nullptr) pGetDpiForWindow = reinterpret_cast<GetDpiForWindow_t>(GetProcAddress(hMod, "GetDpiForWindow"));
done = true;
}

if (pGetDpiForWindow)
Expand Down

0 comments on commit 260c019

Please sign in to comment.