2006. szeptember 22., péntek

Get a TForm's normal bounding rectangle


Problem/Question/Abstract:

I'm trying to find out where a TForm stores its original values for top, left, height and width of the form when it is maximizing. It must be stored somewhere because when I click on restore it goes to its original position and size.

Answer:

Call the GetWindowPlacement function, passing the form's Handle property as the window handle. Here's a sample function that gets a form's normal bounding rectangle:

function GetFormNormalRect(Form: TCustomForm): TRect;
var
  Placement: TWindowPlacement;
begin
  Placement.length := SizeOf(Placement);
  if not GetWindowPlacement(Form.Handle, @Placement) then
    RaiseLastWin32Error;
  Result := Placement.rcNormalPosition;
end;

Nincsenek megjegyzések:

Megjegyzés küldése