tags:

views:

204

answers:

3

Hello,

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

A: 

Try putting this:

TMYForm.Position:=poMainFormCenter;

or

TMYForm.Position:=poOwnerFormCenter;

Before TMYForm.Create(nil);

-S

SP534
+4  A: 

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.

François
A: 

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

Gerry