Dan Morris

I'm developing a Browser Helper Object with a toolbar, using C# and IE7. I use a C# Form to run the toolbar. Everything works great, but I want to add a custom right-click context menu... I can do this as I would in any windows forms application, by handling the right-click event and popping up a menu. The problem is that IE still pops up its own right-click menu also, which just includes the "close toolbar" item. This is _really_ confusing for users; you get two separate menus, one of which has my items and one of which just says "close toolbar".

Does anyone know how to customize - or, even better, remove - the IE context menu that comes up when you right-click on a toolbar

Thanks!

-Dan

Dan Morris

http://research.microsoft.com/~dan



Re: Internet Explorer Extension Development Replacing toolbar right-click context menu

Dan Morris

Months later (and much frustration later), I solved my own problem and thought I'd post my solution...

The problem is that when you associate a .net UserControl with an explorer bar, IE politely pre-populates the "ContextMenu" variable with a menu that has just the "close toolbar" option. I was not using my control's ContextMenu at all (I created a separate ToolStripMenu that I launch on right-click) and was assuming that the mysterious "close toolbar" menu was not at all connected to my .net / forms / UserControl universe. An why would it be As far as I know - other than this mysterious menu population - my control is just a black-box HWND from IE's perspective.

So anyway, it turns out all I had to do to fix this problem was add one line in my control's constructor:

// This clears out the pre-loaded context menu...
this.ContextMenu = new ContextMenu();

No more annoying IE-generated context menu. I can either use the ContextMenu or continue to use my own .net-style ToolStripMenu to handle right-clicks.

-Dan