Skip to content

Commit

Permalink
Windows GUI: Use older API for getting system DPI
Browse files Browse the repository at this point in the history
Use older API to get system DPI for taking DPI scaling into account when setting window size so that it works on older Windows versions.
  • Loading branch information
cjee21 committed May 31, 2024
1 parent fb4fe15 commit 4cb609f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,16 @@ __fastcall TMainF::TMainF(TComponent* Owner)
void __fastcall TMainF::GUI_Configure()
{
//Hard coded
float DPIScale=static_cast<float>(GetSystemDpiForProcess(GetCurrentProcess()))/96;
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
int DPI;
if (osvi.dwMajorVersion >= 10 && (osvi.dwMajorVersion > 10 || osvi.dwMinorVersion > 0 || osvi.dwBuildNumber >= 17134))
DPI=GetSystemDpiForProcess(GetCurrentProcess());
else
DPI=GetDeviceCaps(GetDC(NULL), LOGPIXELSX);
float DPIScale=static_cast<float>(DPI)/96;
float ScaledScreenWidth=Screen->Width/DPIScale;
float ScaledScreenHeight=Screen->Height/DPIScale;
Width=500;
Expand Down

0 comments on commit 4cb609f

Please sign in to comment.