Solved

IE 4.0: IDocHostUIHandler::ShowContextMenu (using)

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.

706 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

20 Experts available now in Live!

Get 1:1 Help Now