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


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).


Try overriding CreateParams():

procedure CreateParams(var Params: TCreateParams); override;

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

<< Back to main page