Results 1 to 4 of 4

Thread: Center a Form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation

    How can I center Child on a parent window?

    Thanks
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To center a child form into a MDIparent form use
    Code:
    Form1.Left = (MDI1.ScaleWidth - Form1.ScaleWidth) / 2
    Form1.Top = (MDI1.ScaleHeight - Form1.ScaleHeight) / 2
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Thumbs up

    Thanks very much Vlatko!
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Thumbs up Or just use the move method

    This works, too:
    Code:
        With Form1
            .Move (MDIForm1.ScaleWidth - .Width) / 2, _
                  (MDIForm1.ScaleHeight - .Height) / 2
        End With
    And I don't believe that you use the ScaleWidth (or ScaleHeight) of Form1 to center it. You use ScaleWidth & ScaleHeight of MDIForm1 (parent form), and Width & Height of Form1 (child form).

    Hope that helps!
    ~seaweed

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