Mirror

How to control the positioning of MDI child forms (Views: 100)


Problem/Question/Abstract:

I have written an inventory app in Delphi 4 using MDI forms. Everything seems to work great. The only thing is, that when I open one child form, then close that same child form and reopen it, the form descends a quarter of an inch. As I open other child forms, they keep descending the same quarter inch (or so). After about four open windows, the 5th opens back at the top of the parent form. Is there any way to have child windows open at the top of my parent window (especially when all other child forms have been closed).

Answer:

Try overriding CreateParams():


procedure CreateParams(var Params: TCreateParams); override;

  procedure TNotebook.CreateParams(var Params: TCreateParams);
  begin
    inherited CreateParams(Params); {call the inherited first}
    with Params do
    begin
      X := YourXPos;
      Y := YourYPos;
    end;
  end;

<< Back to main page