diff options
author | George Hazan <ghazan@miranda.im> | 2022-12-07 21:07:44 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-12-07 21:07:44 +0300 |
commit | 5fdf5d795aaf459c419f5d0f1b67704cdb8d8db0 (patch) | |
tree | d1e30a022f20865909e184085aa33bd4a4ddcff7 | |
parent | 2d52adb9c103a1947eeb513d958c92a0e062394d (diff) |
valid hipdi initialization
-rw-r--r-- | src/mir_core/src/Windows/miranda.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/mir_core/src/Windows/miranda.cpp b/src/mir_core/src/Windows/miranda.cpp index f7d8571191..36f75e4ea1 100644 --- a/src/mir_core/src/Windows/miranda.cpp +++ b/src/mir_core/src/Windows/miranda.cpp @@ -241,6 +241,27 @@ static void __cdecl compactHeapsThread(void*) } } +static void EnableDpiAware() +{ + if (HMODULE hInst = GetModuleHandleW(L"user32")) { + typedef void (WINAPI *pfnSetProcessDpiAwarenessContext)(HANDLE); + if (auto *pFunc = (pfnSetProcessDpiAwarenessContext)GetProcAddress(hInst, "SetProcessDpiAwarenessContext")) { + pFunc(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + return; + } + + typedef void (WINAPI *pfnSetProcessDpiAwareness)(DWORD); + if (auto *pFunc = (pfnSetProcessDpiAwareness)GetProcAddress(hInst, "SetProcessDpiAwareness")) { + pFunc(2); + return; + } + + typedef void (WINAPI *pfnSetProcessDPIAware_t)(void); + if (auto *pFunc = (pfnSetProcessDPIAware_t)GetProcAddress(hInst, "SetProcessDPIAware")) + pFunc(); + } +} + MIR_CORE_DLL(void) BeginMessageLoop() { _set_invalid_parameter_handler(&crtErrorHandler); @@ -260,12 +281,8 @@ MIR_CORE_DLL(void) BeginMessageLoop() bufferedPaintUninit = (pfnBufferedPaintUninit)GetProcAddress(hThemeAPI, "BufferedPaintUninit"); } - if (g_bEnableDpiAware) { - typedef BOOL (WINAPI *pfnSetProcessDPIAware_t)(void); - auto *pFunc = (pfnSetProcessDPIAware_t)GetProcAddress(GetModuleHandleW(L"user32"), "SetProcessDPIAware"); - if (pFunc != nullptr) - pFunc(); - } + if (g_bEnableDpiAware) + EnableDpiAware(); if (bufferedPaintInit) bufferedPaintInit(); |