4
votes

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

1
You can use JediVCL library, where there are TJvFormPlacement and TJvFormStorage components that automatically save/restore form's bounds to/from registry, ini or DBArioch 'The

1 Answers

7
votes

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.