|
-
Aug 31st, 2015, 12:45 PM
#1
Thread Starter
Fanatic Member
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
-
Aug 31st, 2015, 01:33 PM
#2
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
-
Aug 31st, 2015, 01:45 PM
#3
Thread Starter
Fanatic Member
Re: Resize MDI Parent according MDI Child
 Originally Posted by DataMiser
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
-
Aug 31st, 2015, 02:55 PM
#4
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.
-
Aug 31st, 2015, 03:33 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|