Tom
Tom

Reputation: 331

form main + form child stacking issue

I am using main form and child forms.

If I open 2nd child form with

TMYForm.Create(nil);

It does not stack it on the 1st child form top.

Is there any way for 2nd and X'th child form to appear in exact same position as 1st child form?

Or I need to destroy old child form while creating new one (as stacking is done automatically)?

Upvotes: 0

Views: 412

Answers (3)

Gerry Coll
Gerry Coll

Reputation: 5975

If you have references to the child forms, use Form2.BoundsRect := Form1.BoundsRect

Upvotes: 0

Francesca
Francesca

Reputation: 21650

That is the expected behavior. Without specifying otherwise, Forms will open on the right and down from the position of the previously opened.
If you want to control the position of your form, change its Position property to poDesigned, but you have to set its Top and Left properties to ensure it'll be visible.
Or you can used some presets: poDesktopCenter, poMainFormCenter, poOwnerFormCenter or poScreenCenter.

Upvotes: 4

SP534
SP534

Reputation: 16

Try putting this:

TMYForm.Position:=poMainFormCenter;

or

TMYForm.Position:=poOwnerFormCenter;

Before TMYForm.Create(nil);

-S

Upvotes: 0

Related Questions