Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vb.net mdi child title bar not hiding

Tags:

.net

vb.net

mdi

I have an issue hiding the title bar of a mdi child form in maximized state within a mdi parent form in .NET.

Here's what I have at design & run time: enter image description here

Here is the new() of my MDI child form:

Public Sub New(ByRef pParent As Form)
    MyBase.New()
    Me.MdiParent = pParent
    fParent = pParent
    Me.Text = ""
    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    Me.WindowState = FormWindowState.Normal
    Me.MinimizeBox = False
    Me.MaximizeBox = False
    Me.ControlBox = False
    Me.ShowIcon = False
    Me.ShowInTaskbar = False
    Me.SizeGripStyle = Windows.Forms.SizeGripStyle.Hide
    Me.Dock = DockStyle.Fill
End Sub

I've tried FormWindowState.Maximized and DockStyle.None instead but the result was the same.

On the parent container, to change from a child to another I use this function:

Protected Sub SetActiveScreen(ByVal pChildForm As tWizardForm)
    If pChildForm Is Nothing Then Exit Sub
    If fActiveScreen Is pChildForm Then Exit Sub

    Dim hg As New tHourglass
    Try
       fActiveScreen = pChildForm
       fActiveScreen.Show()
       fActiveScreen.BringToFront()
       For Each aForm In MdiChildren
          If aForm IsNot fActiveScreen Then aForm.Hide()
       Next
       fActiveScreen.Execute()
       UpdateCaption()
    Finally
       hg.Dispose()
    End Try    
End Sub

At design I've set the parent property IsMdiContainer = True.

Where did I go wrong or what have I missed ? Plus this kind of double buttons on the child title bar is really strange. When I click one of the maximize buttons I end up with the same result: enter image description here .

The resulting title bar buttons cannot be clicked.

Thank you for any help !

like image 544
Joel Avatar asked Jul 08 '14 08:07

Joel


3 Answers

Here is your exact answer. It will solve your problem.

Add a MenuStrip to MDI form and make it invisible (Visible = false)

like image 167
user3989801 Avatar answered Oct 16 '22 10:10

user3989801


I got this to working by:

  1. Set the child Dock to Fill
  2. Set the child WindowState to Normal (this was the magic bullet)
  3. Use the Show method, not the Focus method
like image 2
Mark Avatar answered Oct 16 '22 12:10

Mark


Try moving

 Me.MaximizeBox = False

to the child form's Load event, this seemed to work in my project.

like image 1
Benno Avatar answered Oct 16 '22 12:10

Benno