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
Solved

IE 4.0: IDocHostUIHandler::ShowContextMenu (using)

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 21
string initialization in java 11 115
ffmpeg - "rtsp://...... Operation not permitted" 4 86
Message not shown 5 67
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: 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.

837 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