-
Is there anyway that I can get my MDI child forms to appear in the center of the parent form without jumping from the upper left corner?
The child forms always seem to start in the upper left corner and then move to the middle. This is annoying because it flickers briefly in the upper left corner before moving to the center.
I tried using the Sleep API and making the form invisible (along with a DoEvents) until after the move, but neither worked.
Does anyone know how to prevent the child form from appearing until it is in the center of the parent form?
Max Thx.
-
Here is a little example. I have a menu called mnuTest on MDI form from which I open Form1, which is an MDIChild.
In MDIForm
Code:
Private Sub mnuTest_Click()
Form1.Show
End Sub
In Form1
Code:
Private Sub Form_Load()
Me.Left = (MDIForm1.Width - Me.Width) / 2
Me.Top = (MDIForm1.Height - Me.Height) / 2
End Sub
Regards,
-
Thanks
for the reply Serge. I was able to get the child Form centered using this code:
Code:
Move ((frmParent.ScaleWidth - Me.ScaleWidth) / 2), ((frmParent.ScaleHeight - Me.ScaleHeight) / 2)
My problem was (and continues to be) that the child form first starts at a position of "0,0" and then moves to the Center. You can actually see it jump, which is what I've been trying to correct.
I created a small app that only has an MDI child and parent form. I found that the child form shows up centered and you don't see it move from the upper left-had corner. This has led me to the conclusion that the other processing that's occurring when the child form in being loaded is causing the problem. However, I do believe that I know how to fix it. I'll re-post if I have any further problems.
Thanks again.
-
Update
Just a quick note to let everyone know that I figured it out. :) Thanks for the help.