Making Controls Resize with the MDI Child form
Page 1 of 110 Replies - 7821 Views - Last Post: 15 February 2012 - 06:19 AM
#1
Making Controls Resize with the MDI Child form
Posted 23 January 2011 - 03:18 PM
Replies To: Making Controls Resize with the MDI Child form
#2
Re: Making Controls Resize with the MDI Child form
Posted 23 January 2011 - 03:23 PM
#3
Re: Making Controls Resize with the MDI Child form
Posted 23 January 2011 - 05:38 PM
hawkvalley1, on 23 January 2011 - 03:23 PM, said:
I will definitely look into that. Thank you for the suggestion. Always appreciated.
#4
Re: Making Controls Resize with the MDI Child form
Posted 24 January 2011 - 05:24 AM
stevesmith54, on 23 January 2011 - 05:38 PM, said:
hawkvalley1, on 23 January 2011 - 03:23 PM, said:
I will definitely look into that. Thank you for the suggestion. Always appreciated.
so far I have not been successful in making this work. When I maximize thr form it does not display right. Are there any other properties on the form that need to be set in order for this to work?
#5
Re: Making Controls Resize with the MDI Child form
Posted 24 January 2011 - 09:42 AM
#6
Re: Making Controls Resize with the MDI Child form
Posted 25 January 2011 - 11:25 AM
On my form I first declare a global (for the form) variable Ctrl as follows.
Dim Ctrl As Control
In my SizeChaged handling subroutine, I declare an SizeF type variable as follows.
Dim ResizeFactor As System.Drawing.SizeF
Then in my SizeChanged handling subroutine, I instantiate my SizeF variable and iterate through the controls as follows.
If Me.WindowsViewState = FormWindowState.Maximize
ResizeFactor = New System.Drawing.SizeF(1.24, 1.24)
For Each Ctrl In Me.Controls
Ctrl.Scale(ResizeFactor)
Next
End If
This is very simple from a coding standpoint and it should work but doesn't. The AutoSize property on every control is set to "True", the the AutoScaleMode property is set to ...Inherit, and the AutoSizeMode property is set to ...GrowOnly (without which the form itself will not resize. Any advice or help will be greately appreciated. I feel rahter stupid right now and am probably missing something simple. Thanks.
#7
Re: Making Controls Resize with the MDI Child form
Posted 25 January 2011 - 11:37 AM
#8
Re: Making Controls Resize with the MDI Child form
Posted 25 January 2011 - 01:18 PM
hawkvalley1, on 25 January 2011 - 11:37 AM, said:
The code gets executed whether I make my subroutine handle the form.Resize event or the form.SizeChanged event. It appears that both events are fired with the form gets resizes or maximized.
I did find some examples where a global variable was declared for the original height and width and that they are compared with the new height and width after the resize. As I work on this I do have one question. How will the height and width calculations be affected by different size monitors? My goal is to make it work the same way regardless of the monitor. Thanks.
#9
Re: Making Controls Resize with the MDI Child form
Posted 25 January 2011 - 01:54 PM
#10
Re: Making Controls Resize with the MDI Child form
Posted 15 February 2012 - 05:51 AM
Private Sub Form_Load()
Left = (Screen.Width - Width) / 2
Top = (Screen.Height - Height) / 2
List1.AddItem Form1.Width
List1.AddItem Form1.Height
List1.AddItem Form1.Left
List1.AddItem Form1.Top
List1.AddItem Drive1.Width
List1.AddItem Drive1.Height
List1.AddItem Drive1.Left
List1.AddItem Drive1.Top
List1.AddItem Dir1.Width
List1.AddItem Dir1.Height
List1.AddItem Dir1.Left
List1.AddItem Dir1.Top
List1.AddItem File1.Width
List1.AddItem File1.Height
List1.AddItem File1.Left
List1.AddItem File1.Top
List1.AddItem Command1.Width
List1.AddItem Command1.Height
List1.AddItem Command1.Left
List1.AddItem Command1.Top
List1.AddItem Command1.Font.Size
End Sub
Private Sub Form_Resize()
Drive1.Width = Form1.Width * List1.List(4) / List1.List(0)
Drive1.Left = Form1.Width * List1.List(6) / List1.List(0)
Drive1.Top = Form1.Height * List1.List(7) / List1.List(1)
Dir1.Width = Form1.Width * List1.List(8) / List1.List(0)
Dir1.Height = Form1.Height * List1.List(9) / List1.List(1)
Dir1.Left = Form1.Width * List1.List(10) / List1.List(0)
Dir1.Top = Form1.Height * List1.List(11) / List1.List(1)
File1.Width = Form1.Width * List1.List(12) / List1.List(0)
File1.Height = Form1.Height * List1.List(13) / List1.List(1)
File1.Left = Form1.Width * List1.List(14) / List1.List(0)
File1.Top = Form1.Height * List1.List(15) / List1.List(1)
Command1.Width = Form1.Width * List1.List(16) / List1.List(0)
Command1.Height = Form1.Height * List1.List(17) / List1.List(1)
Command1.Left = Form1.Width * List1.List(18) / List1.List(0)
Command1.Top = Form1.Height * List1.List(19) / List1.List(1)
Command1.Font.Size = List1.List(20) * Form1.Height / List1.List(1)
End Sub
#11
Re: Making Controls Resize with the MDI Child form
Posted 15 February 2012 - 06:18 AM
EDIT:
Actually, I remember this a while back and so I went on a search. Just gotta remember you're not HawkValley anymore
Resizing controls with a form
This post has been edited by CharlieMay: 15 February 2012 - 06:54 AM
|
|

New Topic/Question
Reply




MultiQuote




|