Thiago Dias
Thiago Dias

Reputation: 121

Delphi Form Restored State Position and Size

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

Upvotes: 4

Views: 1471

Answers (1)

David Heffernan
David Heffernan

Reputation: 613441

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.

Upvotes: 7

Related Questions