Skip to content

Commit

Permalink
Merge pull request #840 from cjee21/windows-hidpi
Browse files Browse the repository at this point in the history
Windows GUI: Improve window size for high DPI
  • Loading branch information
JeromeMartinez authored May 23, 2024
2 parents 4053061 + 501f435 commit c9c6962
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,21 @@ __fastcall TMainF::TMainF(TComponent* Owner)
void __fastcall TMainF::GUI_Configure()
{
//Hard coded
float DPIScale=static_cast<float>(GetSystemDpiForProcess(GetCurrentProcess()))/96;
float ScaledScreenWidth=Screen->Width/DPIScale;
float ScaledScreenHeight=Screen->Height/DPIScale;
Width=500;
Height=400;
if (Screen->Width>=1024)
if (ScaledScreenWidth>=1024)
Width=700;
if (Screen->Width>=1280)
if (ScaledScreenWidth>=1280)
Width=830;
if (Screen->Height>=768)
if (ScaledScreenHeight>=768)
Height=500;
if (Screen->Height>=1024)
if (ScaledScreenHeight>=1024)
Height=600;
Width*=DPIScale;
Height*=DPIScale;
Left=(Screen->Width-Width)/2;
Top=(Screen->Height-Height)/2;

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

0 comments on commit c9c6962

Please sign in to comment.