Skip to content

Commit

Permalink
Windows GUI: Improve window size for high DPI
Browse files Browse the repository at this point in the history
Take DPI scaling into account when setting window size.
  • Loading branch information
cjee21 committed May 22, 2024
1 parent 4053061 commit b9224da
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,17 @@ void __fastcall TMainF::GUI_Configure()
//Hard coded
Width=500;
Height=400;
if (Screen->Width>=1024)
float DPIScale=static_cast<float>(GetSystemDpiForProcess(GetCurrentProcess()))/96;
if (Screen->Width/DPIScale>=1024)
Width=700;
if (Screen->Width>=1280)
if (Screen->Width/DPIScale>=1280)
Width=830;
if (Screen->Height>=768)
if (Screen->Height/DPIScale>=768)
Height=500;
if (Screen->Height>=1024)
if (Screen->Height/DPIScale>=1024)
Height=600;
Width*=DPIScale;
Height*=DPIScale;
Left=(Screen->Width-Width)/2;
Top=(Screen->Height-Height)/2;

Expand Down Expand Up @@ -2064,4 +2067,3 @@ void __fastcall TMainF::DestroyWnd()
DragAcceptFiles(Handle, false);
TForm::DestroyWnd();
}

0 comments on commit b9224da

Please sign in to comment.