From a798474bdc78e55c0909eb424a811ce1baa8d0d9 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 19 Sep 2018 12:58:51 +0200 Subject: [PATCH] Resolve warning popup when GetDpiForWindow() is not available The GetDpiForWindow() Win32 API was introduced in User32.dll with Windows 10. Since we have a fallback case when this API is not present, avoid popping up the wxWidgets warning. Furthermore, performance was improved by introducing a flag to prevent keep looking for GetDpiForWindow() on each call. --- include/wxex/private/tlwgeom.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/wxex/private/tlwgeom.h b/include/wxex/private/tlwgeom.h index 9b325f6..87f081e 100644 --- a/include/wxex/private/tlwgeom.h +++ b/include/wxex/private/tlwgeom.h @@ -289,10 +289,13 @@ private: wxASSERT(dpiVert); #if wxUSE_DYNLIB_CLASS - typedef HRESULT(WINAPI *GetDpiForWindow_t)(HWND); + typedef UINT(WINAPI *GetDpiForWindow_t)(HWND); + static bool s_checkedGetDpiForWindow = false; static GetDpiForWindow_t s_pfnGetDpiForWindow = NULL; - if (!s_pfnGetDpiForWindow && s_dllUser32.IsLoaded()) - s_pfnGetDpiForWindow = (GetDpiForWindow_t)s_dllUser32.GetSymbol(wxT("GetDpiForWindow")); + if (!s_checkedGetDpiForWindow && s_dllUser32.IsLoaded()) { + s_pfnGetDpiForWindow = (GetDpiForWindow_t)s_dllUser32.RawGetSymbol(wxT("GetDpiForWindow")); + s_checkedGetDpiForWindow = true; + } if (s_pfnGetDpiForWindow) { *dpiHorz = *dpiVert = s_pfnGetDpiForWindow(hWnd);