Context Menu on Interop OCX/Control

JillN

New member
Joined
Jun 15, 2006
Messages
1
Programming Experience
5-10
I have a non .NET control that i'm using on a Windows form using the Interop Dll. This control has no place (no property) to set the Context Menu, so I have code in the mouse down event to show my context menu.

But when the menu displays, all of the menu items are disabled.

Here's some code samples of setting up the context menu (copied from a MainMenu menuitem), and showing/popping up the menu:

'Duplicate the menu from a MainMenu MenuItem - this avoids the menu label, and only shows the menu items from the menu mnuView
For I = 0 To mnuView.MenuItems.Count - 1
Dim mnu1 As MenuItem = Me.mnuView.MenuItems(I).CloneMenu
Me.ContextMenu1.MenuItems.Add(mnu1)
Me.ContextMenu1.MenuItems(I).Enabled = True
Next

Next, in the Mouse_Down event of the interop Control:

If e.button = 2 Then ' The right mouse button
Me.ContextMenu1.Show(Me.IDMViewerCtrl1, New System.Drawing.Point(e.x, e.y))
End If

But the above codes opens up teh Context Menu with all items disabled. I've assigned teh Context Menu to teh Form.ContextMenu property, and it works fine if I click on the Form, but not when I click on the interop Control.

Anyone have any suggestions??

THANKS!!
 
Back
Top