Solved

IE 4.0: IDocHostUIHandler::ShowContextMenu (using)

Posted on 1998-01-01
1
516 Views
Last Modified: 2013-11-20
I'm hosting IE 4.0 as an ActiveX control ("Microsoft Web Browser" is the actual name of the ActiveX control from the SDK)

Anyway, it's pretty cool, and does most of what I want, but I do need to provide my own pop-up context menu. (That thing that pops up when you right click on a link or pic on the web page)

I've used IDocHostUIHandler, and have overridden ShowContextMenu.  When the user right-clicks on the link, my overridden ShowContextMenu works fine (It goes to my method, and, because I return S_OK, the browser doesn't display its pop-up) but... I need to find out what the context menu was brought up from (e.g., the link, pic, et al. that the user right-clicked on.)

The code looks like:

HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler::ShowContextMenu(
                        DWORD dwID,
                        POINT* pptPosition,
                        IUnknown* pCommandTarget,
                        IDispatch* pDispatchObjectHit)
{
      METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler)
    // Display Custom Context menu... How????
       
    return S_OK; // We've shown our own context menu. MSHTML.DLL will no longer try to show its own.
}

It sort of looks like IDispatch might have some info about what was clicked on, but is always NULL.  I COULD use what IUnknown points to, but don't know what the correct object is.  (I'm not an expert at COM/ActiveX yet, so may just be missing a simple way to find out what IUnknown points to)

Anyway, if you know how to do this, or can point me in the right direction, it would be VERY helpfull.

(If it's helpfull, I'm basing this off of the IE 4.0 SDK example code "Driller" in \INetSDK\samples\Drill"
0
Comment
Question by:ratajik
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 500 total points
ID: 1313367
I don't have the reference handy (I'm working from another computer), but it looks like from the function declaration that the point is where the user clicked the mouse button, so you would need to create your own popup menu and display that at the specified location (see TrackPopupMenu()).

It appears that pCommandTarget is the pointer to object that you can query to find out what that object is (use pCommandTarget->QueryInterface()). I would also bet that to save time, IE also passed you the IDispatch pointer of that object through pDispatchObjectHit (i.e. if you use pCommandTarget->QueryInterface(IID_DISPATCH, (void**)&myDispatch); that myDispatch would have the same value as pDispatchObjectHit).

Let me know if this doesn't work and I'll see if I can come up with an example when I get home.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
email obfuscation 4 29
while loop over for loop 7 116
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,268
JQuery serialize and unserialize 8 184
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question