Getting Context Menu Information

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jamie S (creamer72_at_hotmail.com)
Date: 07/16/04


Date: 16 Jul 2004 04:18:00 -0700

Hi,

Ive overridden the context menu and want to gain the URL, when a user
right clicks on a link (anchor).
However, although my code compiles fine, it crashes when
right-clicking on a link. I have narrowed the problem to my
queryinterface line. Has anyone got an idea of where i went wrong?
Thanks.

HRESULT FAR EXPORT CCustomControlSite::XDocHostUIHandler::ShowContextMenu(
                                DWORD dwID,
                                POINT* /*pptPosition*/,
                                IUnknown* /*pCommandTarget*/,
                                IDispatch *pdispReserved)
{
        METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler)

        if (dwID == 6) //an anchor (works fine)
        {
                IHTMLAnchorElement *pElem = NULL;
                BSTR bstrURL;
                
pdispReserved->QueryInterface(IID_IHTMLAnchorElement,(void**)&pElem);
        
                 pElem->get_href(&bstrURL);

        }
                else
                AfxMessageBox("Default Menu");
        
return S_OK;
}



Relevant Pages

  • Re: Development Advice
    ... > a cost to try and avoid the "Kick the wall 1000x to gain Master Ninja" ... kicking a wall trains kicking in the context of walls. ...
    (rec.games.roguelike.development)
  • Re: Printing htmal pages to paper
    ... so the context surrounding must provide it at least. ... *extra* click me words since anchor elements can contain appropriate ... I can imagine an objection. ...
    (comp.infosystems.www.authoring.html)
  • Re: a name vs. span id?
    ... What is the context of the question? ... I was viewing the HTML source of some webpage, ... All the webpages / webapps I've worked, thus far, on have used anchor ...
    (comp.infosystems.www.authoring.html)
  • Re: CDialog contructor with nIDTemplate
    ... You are suggesting that you are doing this in a DLL. ... There is not enough context here ot answer the question. ... The code compiles ... But the m_lpszTemplateName remains null in the constructor and hence ...
    (microsoft.public.vc.mfc)
  • Re: Anchor Question
    ... The combination of chain and anchor weigh about 150 pounds ... You used it in context with respect to not being able to retrieve the anchor.... ...
    (rec.boats)