Results 1 to 4 of 4

Thread: One More Thing!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600
    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.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    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,

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    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.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up Update

    Just a quick note to let everyone know that I figured it out. Thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width