Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ContextMenu in ActiveX Controls

Status
Not open for further replies.

jalfano

Programmer
Aug 6, 2003
1
US
I am trying to add a Context Menu to an ActiveX control (LeadTools Image Control) that I have on my main form. I have tried two different approaches that don't seem to work.

1.Since the control is wrapped using the AxHost class, I tried setting the ContextMenu property (which doesn't show up in design mode for some reason, so I had to set it manually) to my context menu.

axLEADImage.ContextMenu = contextMenuLead;

This did nothing. However if I do this to a normal control, it works fine on a right-click.

2. I also tried calling the ContextMenu.Show method within the MouseButtonUp event on the ActiveX control.

private void OnAxLeadMouseUp(object sender, AxLEADLib._DLeadEvents_MouseUpEvent e)
{
AxLEADLib.AxLEAD AxLead = (AxLEADLib.AxLEAD)sender;

if(e.button == 2) //Lead Tools Right Mouse Button
{
contextMenuLead.Show(AxLead, new Point(e.x, e.y));
}
}

This actually displays the ContextMenu as desired, but all the MenuItems are disabled even though their properties are set to enabled. Any Suggestions as to what I am doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top