CHtmlView OnMouseClick method - Programmer

This is a discussion on CHtmlView OnMouseClick method - Programmer ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: CHtmlView OnMouseClick method

  1. CHtmlView OnMouseClick method

    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

  2. Re: CHtmlView OnMouseClick method

    Hi John,

    > 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?


    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.

    > 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.


    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




  3. Re: CHtmlView OnMouseClick method

    if you use MFC6, please visit http://support.microsoft.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" дʼ
    news:40bb7eb4$0$26358$9b4e6d93@newsread4.arcor-online.net...
    > Hi John,
    >
    > > 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?

    >
    > 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.
    >
    > > 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.

    >
    > 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
    >
    >
    >




+ Reply to Thread