Results 1 to 5 of 5

Thread: Centering a MDIChild form in the MDI window

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    I try to set the StartupPosition property for an MDI Child form to start up in the center of the MDI form. It returns an error. Something like "Cannot set this property". I don't remember.

    The child forms normally start up in the upper left hand corner of the MDI window and cascade from there.

    It's not important but if anyone knows how to set the startup position for an MDI child form that would be great.

    Just curious.

  2. #2
    Guest
    Try this.

    Code:
    Private Sub MDIForm_Load()
    
        Form1.Move (Me.ScaleWidth / 2) - (Form1.Width / 2), (Me.ScaleHeight / 2) - (Form1.Height / 2)
    
    End Sub

  3. #3
    Guest

    Thumbs up

    u can try these too....

    Private Sub MDIChildForm_Load()

    me.Move (Me.Parent.ScaleWidth / 2) - (me.Width / 2), (Me.Parent.ScaleHeight / 2) - (Me.Height / 2)

    End Sub

  4. #4
    Junior Member
    Join Date
    Jul 2001
    Location
    na
    Posts
    26
    I used Megatron's code. It doesn't seem to be working correctly. The child form ends up partially off of the left side of the screen. Here is the code that I used:

    Private Sub MDIForm_Load()

    frmUpdate.Move (Me.ScaleWidth / 2) - (frmUpdate.Width / 2), (Me.ScaleHeight / 2) - (frmUpdate.Height / 2)

    End Sub

    I put this in the mdiform's code. My mdiform is set to be maximized to the user's screen on load.

  5. #5
    Junior Member
    Join Date
    Jul 2001
    Location
    na
    Posts
    26
    I was able to get it to work by changing it to this:


    Private Sub Form_Resize()

    Me.Left = (MDIForm1.Width - Me.Width) / 2
    Me.Top = (MDIForm1.Height - Me.Height) / 2
    End Sub

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