To customize the context menu derive your object form ICustomDoc and call SetUIHandler. This is called in the document complete handler within my object only for certain web pages. The rest of the time the default IE context menu is shown. . Once you have hooked up the UI handler in the ShowContextMenu method you need to build and show the context menu. Hope this helps. (pseudo code below)
case DISPID_DOCUMENTCOMPLETE:
// [0]: Document URL - VT_BYREF|VT_VARIANT
// [1]: An object that evaluates to the top-level or frame
// WebBrowser object corresponding to the event.
spWebBrowser2 = pDispParams->rgvarg[1].pdispVal;
// Get the WebBrowser's document object
hr = spWebBrowser2->get_Document(&spDisp);
if (SUCCEEDED(hr) && m_bSetSite)
{
// Verify pointer to a MSHTML::IHTMLDocument2
// interface by querying for the MSHTML::IHTMLDocument2 interface (through smart pointers)
MSHTML::IHTMLDocument2Ptr spHTML;
spHTML = spDisp;
// Check not not dealing with Explorer or
// an Acrobat Reader (pdf) file.
if (spHTML.GetInterfacePtr() && IsDocumentSafe())
{
ICustomDocPtr spCustomDoc;
hr = spHTML->QueryInterface(IID_ICustomDoc, (void**)&spCustomDoc);
if (spCustomDoc)
{
//Only SetUIHandler for certain web pages determined in CheckHandler()
int dHandlerCode = CheckHandler();
if (dHandlerCode!=0)
{
spCustomDoc->SetUIHandler(this);
..........
}
}
}
}
break;
---------------------------------------
STDMETHODIMP CYour_Main_Object::ShowContextMenu(DWORD dwID, POINT FAR* ppt, IUnknown FAR* pcmdTarget, IDispatch FAR* pdispReserved)
{
return m_YourUIClass.ContextMenu(dwID, ppt, pcmdTarget,pdispReserved);
}