Solved

IE 4.0: IDocHostUIHandler::ShowContextMenu (using)

Posted on 1998-01-01
1
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 358
has22 challenge 11 110
fix34  challenge 9 181
firstChar challenge 13 148
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

734 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