Skip to content

Commit

Permalink
Windows GUI: Use older API for getting system DPI, update2
Browse files Browse the repository at this point in the history
Implement delayed loading of user32.dll and restore GetSystemDpiForProcess. Should work on Windows 7 to 11 now.
  • Loading branch information
cjee21 committed Jun 1, 2024
1 parent 80dc38b commit 94a1b58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Project/BCB/GUI/MediaInfo_GUI.cbproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<Icon_MainIcon>..\..\..\Source\Resource\Image\MediaInfo.ico</Icon_MainIcon>
<ILINK_DelayLoadDll>user32.dll;$(ILINK_DelayLoadDll)</ILINK_DelayLoadDll>
</PropertyGroup>
<ItemGroup>
<LibFiles Condition="'$(Platform)'=='Win32'" Include="$(BDSLIB)\win32\release\wininet.lib">
Expand Down
4 changes: 2 additions & 2 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(DPI)/96;
Expand Down

0 comments on commit 94a1b58

Please sign in to comment.