CHtmlView OnMouseClick method

CHtmlView OnMouseClick method

Post by homecur » Thu, 27 May 2004 07:36:48


Hi, everyone:

I am using a CHtmlView in my SDI program. Everytime the mouse is right
clicked, a stand IE menu is popped up. How can I change this menu and
add me own items? I also want add different items depending on the
location or objects clicked. For example, if a image is clicked, I
want to add something menu item that is different when a link is
clicked.


Thanks,

John
 
 
 

CHtmlView OnMouseClick method

Post by Frank Renn » Wed, 02 Jun 2004 03:56:06

Hi John,


typically you would do this by implementing the interface IDocHostUIHandler
on the ActiveX Control client site that hosts the web browser control. In the
MSDN Library there is a good description of the interface and especially of
how to replace or modify the browser context menu. In short: each time the web
browser control is about to show a context menu, it first calls ShowContextMenu
on the IDocHostUIHandler interface. The implementor now can decide whether
to let the web browser control show the context menu or not. In the latter case
you could show your own context menu or load the web browser context menu,
modify it and then show it.

The bad news is: there is no way to implement additional interfaces on the MFC
ActiveX Control client site. All that stuff (COccManager, COleControlContainer,
COleControlSite) simply is not flexible enough to allow for additional interfaces.

The only solution from my point of view (apart from implementing it from scratch)
is to use the ATL client site implementation. It does implement IDocHostUIHandler
and delegates to an interface called IDocHostUIHandlerDispatch which is seman-
tically identical with IDocHostUIHandler (a few differences in structure). The ATL
class CAxWindow, which is used as a representative of the ActiveX Control at
the client side, provides a method SetExternalUIHandler which expects such an
IDocHostUIHandlerDispatch interface.


ShowContextMenu is being passed the mouse cursor position at least. Should
be possible to figure out the HTML element beneath using the DOM.

HTH
Frank

 
 
 

CHtmlView OnMouseClick method

Post by Jiangsheng » Wed, 04 Aug 2004 12:39:14

if you use MFC6, please visit http://www.yqcomputer.com/ ?kbid=236312
Q236312 HOWTO: Disable the Default Pop-up Menu for CHtmlView and follow its
instructions.
IDocHostUIHandler is implemented by MFC7 by default, but better if you step
into MFC code to see what happens.

recommended reading:
Q241750 BUG: CHtmlView Leaks Memory by Not Releasing BSTRs in Several
Methods
Q196835 HOWTO: Override the MFC Default Control Containment



"Frank Renner" < XXXX@XXXXX.COM >

IDocHostUIHandler
the
of
web
ShowContextMenu
case
MFC
COleControlContainer,
interfaces.
scratch)
IDocHostUIHandler
seman-
The ATL
at
an