B
Brian Tkatch
Not sure if this is the way it's supposed to be, but after a Layout
event on an MDI form, the form's new width is set, but the MDIClient's
width is not.
As an example, start a new Windows Application, and for the code use:
Public Class Form1
Dim TextBox1, TextBox2, TextBox3 As New TextBox
Dim The_MDIClient As MdiClient
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
Me.Height = 600
TextBox1.Location = New System.Drawing.Point(1, 1)
TextBox2.Location = New System.Drawing.Point(71, 1)
TextBox3.Location = New System.Drawing.Point(121, 1)
TextBox1.Size = New System.Drawing.Size(70, Me.Height - 50)
TextBox2.Size = New System.Drawing.Size(50, Me.Height - 50)
TextBox3.Size = New System.Drawing.Size(50, Me.Height - 50)
TextBox1.Multiline = True
TextBox2.Multiline = True
TextBox3.Multiline = True
Me.Controls.Add(TextBox1)
Me.Controls.Add(TextBox2)
Me.Controls.Add(TextBox3)
For Each Current_Control As Control In Me.Controls
If TypeOf Current_Control Is MdiClient Then The_MDIClient =
Current_Control
Next
End Sub
Sub Show_Width(ByVal Sub_Name As String)
If The_MDIClient Is Nothing Then Exit Sub
TextBox1.Text += Mid$(Sub_Name, 7) + vbCrLf
TextBox2.Text += The_MDIClient.ClientRectangle.Width.ToString +
vbCrLf
TextBox3.Text += Me.ClientRectangle.Width.ToString + vbCrLf
End Sub
Private Sub Form1_ResizeBegin(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.ResizeBegin
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.ResizeEnd
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
Private Sub Form1_Layout(ByVal sender As Object, ByVal e As
System.Windows.Forms.LayoutEventArgs) Handles Me.Layout
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
End Class
Then resize.
Is this how it should be?
Also, is the MDIClient always the same amount less than the MDI form
itself? In this case, MDIClient.width is 4 less than Me.Width. If this
is constant, i can grab the difference in the Load event and in the
Layout event refer to Me.Width - whatever the difference is to get the
not-yet-updated MDIClient.Width.
B.
event on an MDI form, the form's new width is set, but the MDIClient's
width is not.
As an example, start a new Windows Application, and for the code use:
Public Class Form1
Dim TextBox1, TextBox2, TextBox3 As New TextBox
Dim The_MDIClient As MdiClient
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
Me.Height = 600
TextBox1.Location = New System.Drawing.Point(1, 1)
TextBox2.Location = New System.Drawing.Point(71, 1)
TextBox3.Location = New System.Drawing.Point(121, 1)
TextBox1.Size = New System.Drawing.Size(70, Me.Height - 50)
TextBox2.Size = New System.Drawing.Size(50, Me.Height - 50)
TextBox3.Size = New System.Drawing.Size(50, Me.Height - 50)
TextBox1.Multiline = True
TextBox2.Multiline = True
TextBox3.Multiline = True
Me.Controls.Add(TextBox1)
Me.Controls.Add(TextBox2)
Me.Controls.Add(TextBox3)
For Each Current_Control As Control In Me.Controls
If TypeOf Current_Control Is MdiClient Then The_MDIClient =
Current_Control
Next
End Sub
Sub Show_Width(ByVal Sub_Name As String)
If The_MDIClient Is Nothing Then Exit Sub
TextBox1.Text += Mid$(Sub_Name, 7) + vbCrLf
TextBox2.Text += The_MDIClient.ClientRectangle.Width.ToString +
vbCrLf
TextBox3.Text += Me.ClientRectangle.Width.ToString + vbCrLf
End Sub
Private Sub Form1_ResizeBegin(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.ResizeBegin
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.ResizeEnd
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
Private Sub Form1_Layout(ByVal sender As Object, ByVal e As
System.Windows.Forms.LayoutEventArgs) Handles Me.Layout
Show_Width(System.Reflection.MethodBase.GetCurrentMethod.Name)
End Sub
End Class
Then resize.
Is this how it should be?
Also, is the MDIClient always the same amount less than the MDI form
itself? In this case, MDIClient.width is 4 less than Me.Width. If this
is constant, i can grab the difference in the Load event and in the
Layout event refer to Me.Width - whatever the difference is to get the
not-yet-updated MDIClient.Width.
B.