Adding MDI forms to the Window Menu

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
 
O

OmegaSquared

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
 
O

OmegaSquared

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
 
W

W

I don't see a PopUp event in the list of events and not sure where to
put the "AddHandler" statement
 
L

Lloyd Sheen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top