In a maximized delphi form, how to get form's restored state position and size? I know in .NET we use RestoreBounds
and DesktopBound
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With