Hi GoldTree,
regarding on IE BHO and context menu customization, here is a forum thread
also mentions some suggestion:
#BHO & context menu customization
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1159435&SiteID=1
Also, I've performed some further research, here is some other information
found so far:
========================
For all IE versions up to IE6.0, the best we can do is replace the context
menu by sinking document events, cancellling the oncontextmenu event and
drawing our own context menu. The CreateMenu(), Append/InsertMenuItem() and
TrackPopupMenu() Win32 API calls are required to do this from C++.
One can override the context menu and display a custom one by implementing
IDocHostUIHandler interface in the host application. One problem is that
even if you build the same menu as IE's, there are no CMDID's to invoke
default implementation of IE for all of those commands using
IOleCommandTarget.
1. With IE 4.x one can subclass IE's window(one customer did this in
IDocHostUIHandler::OnContextMenu) and watch for the WM_INITPOPUPMENU
message and wait for the WM_COMMAND message sent when the user selects a
menu item. But with IE 5 onwards, IE calls TrackPopupMenu, gets the command
ID of the item selected and invokes the appropriate functionality using
IOleCommandTarget without generating a WM_COMMAND message. So developers
can no longer rely on this technique from IE 5 onwards.
2. On some occasions, developers may be doing this to prevent the user from
invoking certain menu items (eg: View Source) In this case, it's easier to
disable the menu item. Subclass the webbrowser control window, watch for
WM_INITPOPUPMENU. You will get the HMenu from this which you can
use to go disable/grey out items using the EnableMenuItem or
SetMenuItemInfo methods. Remember to return 0 after processing this message.
* Note that there is still no way to prevent script on the page from
invoking the same commands.
* For menu items that have accelerator keys, you can watch for these
keystrokes in IDocHostUIHandler::TranslateAccelerator.
Some customers tried to watch for WM_MENUSELECT messages and figure out the
last one moused over to determine which was selected. Since there are a lot
of scenarios that will need to be taken care of eg: user dismiised the menu
by clicking outside the context menu, pressed escape or selected using
mouse or keyboard, strongly advise them against using this technique
===========================================
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: <GoldTree@nospam.nospam>
>Subject: Browser Helper Object (BHO) in C#.
[quoted text clipped - 19 lines]
>
>GoldTree