From 94a1b58262b46a95e01de4927b060bda73f5affc Mon Sep 17 00:00:00 2001
From: cjee21 <77721854+cjee21@users.noreply.github.com>
Date: Sat, 1 Jun 2024 16:14:29 +0800
Subject: [PATCH] Windows GUI: Use older API for getting system DPI, update2
Implement delayed loading of user32.dll and restore GetSystemDpiForProcess. Should work on Windows 7 to 11 now.
---
Project/BCB/GUI/MediaInfo_GUI.cbproj | 1 +
Source/GUI/VCL/GUI_Main.cpp | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Project/BCB/GUI/MediaInfo_GUI.cbproj b/Project/BCB/GUI/MediaInfo_GUI.cbproj
index 0e997dc6a..9fefe9ec8 100644
--- a/Project/BCB/GUI/MediaInfo_GUI.cbproj
+++ b/Project/BCB/GUI/MediaInfo_GUI.cbproj
@@ -111,6 +111,7 @@
$(BDS)\bin\default_app.manifest
PerMonitorV2
..\..\..\Source\Resource\Image\MediaInfo.ico
+ user32.dll;$(ILINK_DelayLoadDll)
diff --git a/Source/GUI/VCL/GUI_Main.cpp b/Source/GUI/VCL/GUI_Main.cpp
index 1e5ad840e..3e4eacc19 100644
--- a/Source/GUI/VCL/GUI_Main.cpp
+++ b/Source/GUI/VCL/GUI_Main.cpp
@@ -248,8 +248,8 @@ void __fastcall TMainF::GUI_Configure()
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
int DPI;
- if (osvi.dwMajorVersion >= 10 && (osvi.dwMajorVersion > 10 || osvi.dwMinorVersion > 0 || osvi.dwBuildNumber >= 17134))
- DPI=GetDeviceCaps(GetDC(NULL), LOGPIXELSX); // GetSystemDpiForProcess(GetCurrentProcess());
+ if (osvi.dwMajorVersion >= 10 && (osvi.dwMajorVersion > 10 || osvi.dwMinorVersion > 0 || osvi.dwBuildNumber >= 14939))
+ DPI=GetDpiForWindow(WindowHandle);
else
DPI=GetDeviceCaps(GetDC(NULL), LOGPIXELSX);
float DPIScale=static_cast(DPI)/96;