Results 1 to 5 of 5

Thread: Resize MDI Parent according MDI Child

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Question Resize MDI Parent according MDI Child

    Hi

    In My project there some forms with mdiparent = true , I would like that MdiParent resize acoording properties WIDTH and HEIGHT from MDI Child

    I Would like too , when the user click in button Maximize control, the MDI CHILD to be in center MDI Parent or The user do not get click in button maximize


    Tia

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Resize MDI Parent according MDI Child

    Use the height and width properties of one form and then set the other forms height and width as needed.
    To center simply do a little math checking the height and width of the parent subtract the height and width of the child and divide by 2.

    You can disable the maximize button in the forms properties

  3. #3

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Resize MDI Parent according MDI Child

    Quote Originally Posted by DataMiser View Post
    Use the height and width properties of one form and then set the other forms height and width as needed.
    To center simply do a little math checking the height and width of the parent subtract the height and width of the child and divide by 2.

    You can disable the maximize button in the forms properties
    Thank you, but in MDI Parent there is not maximize button propertie

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Resize MDI Parent according MDI Child

    Is this what you are looking for maybe?

    Code:
    ' in MDI child's form load event
        Dim adjCx As Single, adjCy As Single
        With MDIForm1
            adjCx = Me.Width - .ScaleWidth
            adjCy = Me.Height - .ScaleHeight
            .Move .Left, .Top, .Width + adjCx, .Height + adjCy
        End With
    Note. This isn't perfect.

    1) Code assumes MDI parent scalemode is twips. If something else, use ScaleX & ScaleY to convert parent's ScaleWidth & ScaleHeight to Twips

    2) Ideally, I'd think the left & top position of the MDI parent should change along with the width & height. Positioning of the MDI parent before resizing should determine that. For example, don't want resizing to cause the MDI parent borders to go off the screen

    3) If a smaller MDI child is shown after larger children were shown, the MDI parent will display scrollbars to allow accessing the those previous children

    As far as clicking the MDI child's Close button ( X ) to act as a centering action, probably gonna need handle the Form_QueryUnload event or subclassing for that

    Have fun.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Resize MDI Parent according MDI Child

    Wouldn't setting the Parent's height same as Child's height defeat the purpose of the vertical scrollbar


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Tags for this Thread

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