Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Form Restored State Position and Size

Tags:

winapi

delphi

In a maximized delphi form, how to get form's restored state position and size? I know in .NET we use RestoreBounds and DesktopBound.

like image 333
Thiago Dias Avatar asked Mar 16 '23 06:03

Thiago Dias


1 Answers

This is not exposed by the VCL framework. Instead you need to dip into the Win32 API. The function you need is GetWindowPlacement.

var
  WindowPlacement: TWindowPlacement;
....
WindowPlacement.length := SizeOf(WindowPlacement);
Win32Check(GetWindowPlacement(Form.Handle, WindowPlacement));

The information you need can be found in the WindowPlacement struct. Do beware that the coordinates are reported with respect to the work area rather than the screen.

Generally you want this information so that you can restore it at a later date. Use SetWindowPlacement to do that.

like image 188
David Heffernan Avatar answered Apr 19 '23 22:04

David Heffernan