G
Guest
I've noticed that child forms always seem to show their title bar when they
are first shown in an MdiClient. This is a problem for me because I am
implementing a custom look which requires me to hide the system's title bar
in order to draw my own. I've created a sample that demonstrates the issue:
Public Class Form1
Inherits Windows.Forms.Form
Protected WithEvents Button1 As Windows.Forms.Button
Protected ChildForms() As Windows.Forms.Form
Public Sub New()
MyBase.New()
Me.IsMdiContainer = True
Me.Size = New Drawing.Size(800, 600)
Const n As Integer = 4
Const uBound As Integer = (n - 1)
Dim childForms(uBound) As Windows.Forms.Form
Dim position As Integer = 0
Const delta As Integer = 24
For i As Integer = 0 To uBound
childForms(i) = New Windows.Forms.Form
childForms(i).MdiParent = Me
childForms(i).FormBorderStyle = Windows.Forms.FormBorderStyle.None
childForms(i).ControlBox = False
childForms(i).StartPosition = FormStartPosition.Manual
childForms(i).Location = New Drawing.Point(position, position)
position += delta
Next i
Me.ChildForms = childForms
Me.Button1 = New Windows.Forms.Button
Me.Button1.Text = "Click Me"
Dim topPanel As New Windows.Forms.Panel
topPanel.Height = Me.Button1.Height
topPanel.Dock = DockStyle.Top
topPanel.Controls.Add(Me.Button1)
Me.Controls.Add(topPanel)
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
For i As Integer = 0 To Me.ChildForms.GetUpperBound(0)
Me.ChildForms(i).Visible = (Not Me.ChildForms(i).Visible)
Next i
End Sub
Protected Overrides Sub OnMdiChildActivate(ByVal e As System.EventArgs)
' The following simulates code that might be executed when an MdiChild
is activated, such as merging menus.
Dim duration As New System.TimeSpan(0, 0, 1)
Dim startTime As System.DateTime = System.DateTime.Now
While ((System.DateTime.Now - startTime) < duration)
End While
MyBase.OnMdiChildActivate(e)
End Sub
End Class
Is there any way to prevent the title bar of the MdiChild forms from
appearing when the child forms are first shown?
Thanks for any help!
Lance
are first shown in an MdiClient. This is a problem for me because I am
implementing a custom look which requires me to hide the system's title bar
in order to draw my own. I've created a sample that demonstrates the issue:
Public Class Form1
Inherits Windows.Forms.Form
Protected WithEvents Button1 As Windows.Forms.Button
Protected ChildForms() As Windows.Forms.Form
Public Sub New()
MyBase.New()
Me.IsMdiContainer = True
Me.Size = New Drawing.Size(800, 600)
Const n As Integer = 4
Const uBound As Integer = (n - 1)
Dim childForms(uBound) As Windows.Forms.Form
Dim position As Integer = 0
Const delta As Integer = 24
For i As Integer = 0 To uBound
childForms(i) = New Windows.Forms.Form
childForms(i).MdiParent = Me
childForms(i).FormBorderStyle = Windows.Forms.FormBorderStyle.None
childForms(i).ControlBox = False
childForms(i).StartPosition = FormStartPosition.Manual
childForms(i).Location = New Drawing.Point(position, position)
position += delta
Next i
Me.ChildForms = childForms
Me.Button1 = New Windows.Forms.Button
Me.Button1.Text = "Click Me"
Dim topPanel As New Windows.Forms.Panel
topPanel.Height = Me.Button1.Height
topPanel.Dock = DockStyle.Top
topPanel.Controls.Add(Me.Button1)
Me.Controls.Add(topPanel)
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
For i As Integer = 0 To Me.ChildForms.GetUpperBound(0)
Me.ChildForms(i).Visible = (Not Me.ChildForms(i).Visible)
Next i
End Sub
Protected Overrides Sub OnMdiChildActivate(ByVal e As System.EventArgs)
' The following simulates code that might be executed when an MdiChild
is activated, such as merging menus.
Dim duration As New System.TimeSpan(0, 0, 1)
Dim startTime As System.DateTime = System.DateTime.Now
While ((System.DateTime.Now - startTime) < duration)
End While
MyBase.OnMdiChildActivate(e)
End Sub
End Class
Is there any way to prevent the title bar of the MdiChild forms from
appearing when the child forms are first shown?
Thanks for any help!
Lance