Solved

IE 4.0: IDocHostUIHandler::ShowContextMenu (using)

Posted on 1998-01-01
1
483 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now