Adding MDI forms to the Window Menu

  • Thread starter Thread starter W
  • Start date Start date
W

W

I am trying to add active MDI forms to the window menu of the parent
window according to the link below
http://support.microsoft.com/kb/555284

The Window menu title is multi lingual (which is probably
insignificant).
My menu strip is named MenuStrip1 and
The window menu title is "ÔÈÇßWindowToolStripMenuItem"

It seems that the menu item is successfully added, but i am not able
to see it (probably because i am should not be using the click event).

I need help. Thanks

Public Class Main_Menu ' This is my parent window
Public Class MdiChildInfo
Private myForm As Form

Private Sub New()
End Sub

Public Sub New(ByVal pForm As Form)
Me.myForm = pForm
End Sub

Public Sub Click(ByVal sender As Object, ByVal e As EventArgs)
If (Not Me.myForm Is Nothing) Then
Me.myForm.Activate()
If ((Not Me.myForm.ActiveControl Is Nothing) AndAlso
Not Me.myForm.ActiveControl.Focused) Then
Me.myForm.ActiveControl.Focus()
End If
End If
End Sub
End Class

Private Sub ÔÈÇßWindowToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ÔÈÇßWindowToolStripMenuItem.Click
If Me.MdiChildren.Length > 0 Then
MenuStrip1.ContextMenu = New ContextMenu()
For Each tform As Form In Me.MdiChildren
Dim menuItem As New MenuItem(tform.Text, New
EventHandler(AddressOf New MdiChildInfo(tform).Click))
'Me.MainMenuStrip.ContextMenu.MenuItems.Add(menuItem)
MenuStrip1.ContextMenu.MenuItems.Add(menuItem)

menuItem.Checked = (tform Is MyBase.ActiveMdiChild)
Next
End If
MsgBox(MenuStrip1.ContextMenu.MenuItems.Count)
MenuStrip1.Focus()
End Sub

....
....
End Class
 
Hello, W,

Re: "...(probably because i am should not be using the click event)."

Yes. By the time the Click event is processed, it is too late to show the
modifications you are making to the menu. You must use the PopUp event.

Cheers,
Randy
 
Hello, W,

Re: "...i am not able to see it (probably because i am should not be using
the click event)."

Yes. By the time the click event is processed it is too late to display the
changes you are making to the menu. You must use the PopUp event.

Cheers,
Randy
 
I don't see a PopUp event in the list of events and not sure where to
put the "AddHandler" statement
 
I don't see a PopUp event in the list of events and not sure where to
put the "AddHandler" statement
Yes. By the time the Click event is processed, it is too late to show the
modifications you are making to the menu. You must use the PopUp event.

Cheers,
Randy


Not near workstation with VS but I am sure it is the Opening event you want.

LS
 
Back
Top