Centering within MDI Form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Centering within MDI Form

  1. #1
    Michelle Guest

    Centering within MDI Form


    Can someone please tell me how to center an MDI child form within a parent
    form?

    I'm trying to find a way to code this without having to check the user's
    resolution settings and then coding the screen positions. The property
    "StartupPosition - 2 - CenterScreen" does not work and I tried to use the
    following code:
    --------------------------
    Call Centerform (Me)
    -------------------------
    Sub CenterForm (inform as Form)
    inform.Move (Screen.Width - inform.Width) /2, (screen.Height -
    inform.Height) /2
    End Sub

    However this code doesn't work well if you have a toolbar within the MDI
    form.

    Any help would be appreciated!



  2. #2
    Shawn K. Hall Guest

    Re: Centering within MDI Form

    Michelle,

    Try this:

    '==========
    CenterForm Me, MDIForm1
    '==========
    Sub CenterForm(frm As Form, inFrm As Form)
    frm.Move (inFrm.ScaleWidth - frm.Width) \ 2, (inFrm.ScaleHeight -
    frm.Height) \ 2
    End Sub

    Regards,

    Shawn K. Hall
    Programmer / Analyst
    *Please* post/respond in the newsgroups!
    http://i.am/shawnkhall


    "Michelle" <mychelle@rcn.com> wrote in message
    news:3945603f@news.devx.com...
    >
    > Can someone please tell me how to center an MDI child form within a

    parent
    > form?
    >
    > I'm trying to find a way to code this without having to check the

    user's
    > resolution settings and then coding the screen positions. The

    property
    > "StartupPosition - 2 - CenterScreen" does not work and I tried to

    use the
    > following code:
    > --------------------------
    > Call Centerform (Me)
    > -------------------------
    > Sub CenterForm (inform as Form)
    > inform.Move (Screen.Width - inform.Width) /2, (screen.Height -
    > inform.Height) /2
    > End Sub
    >
    > However this code doesn't work well if you have a toolbar within the

    MDI
    > form.
    >
    > Any help would be appreciated!
    >
    >




  3. #3
    Michelle Guest

    Re: Centering within MDI Form


    Thanks for your help Shawn! Your code worked!

    Michelle

    "Shawn K. Hall" <shawnkhall@iname.com> wrote:
    >Michelle,
    >
    >Try this:
    >
    >'==========
    > CenterForm Me, MDIForm1
    >'==========
    >Sub CenterForm(frm As Form, inFrm As Form)
    > frm.Move (inFrm.ScaleWidth - frm.Width) \ 2, (inFrm.ScaleHeight -
    >frm.Height) \ 2
    >End Sub
    >
    >Regards,
    >
    >Shawn K. Hall
    >Programmer / Analyst
    >*Please* post/respond in the newsgroups!
    >http://i.am/shawnkhall
    >
    >
    >"Michelle" <mychelle@rcn.com> wrote in message
    >news:3945603f@news.devx.com...
    >>
    >> Can someone please tell me how to center an MDI child form within a

    >parent
    >> form?
    >>
    >> I'm trying to find a way to code this without having to check the

    >user's
    >> resolution settings and then coding the screen positions. The

    >property
    >> "StartupPosition - 2 - CenterScreen" does not work and I tried to

    >use the
    >> following code:
    >> --------------------------
    >> Call Centerform (Me)
    >> -------------------------
    >> Sub CenterForm (inform as Form)
    >> inform.Move (Screen.Width - inform.Width) /2, (screen.Height -
    >> inform.Height) /2
    >> End Sub
    >>
    >> However this code doesn't work well if you have a toolbar within the

    >MDI
    >> form.
    >>
    >> Any help would be appreciated!
    >>
    >>

    >
    >



  4. #4
    Shawn K. Hall Guest

    Re: Centering within MDI Form

    You're welcome.

    --
    Shawn K. Hall
    Programmer / Analyst
    *Please* post/respond in the newsgroups!
    http://i.am/shawnkhall


    "Michelle" <mychelle@rcn.com> wrote in message
    news:39457e26$1@news.devx.com...
    >
    > Thanks for your help Shawn! Your code worked!
    >
    > Michelle





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center