function TForm1.WebBrowser1ShowContextMenu(const dwID: Cardinal;
const ppt: PPoint; const pcmdtReserved: IUnknown;
const pdispReserved: IDispatch): HRESULT;
begin
PopupMenu1.Popup(ppt.x, ppt.y); //show our own contextmenu
result := S_OK; // Don't show default menu
end;
위의 코드를 프로그램에 포함 시키면 된다는데..
OnShowContextMenu는 IDocHostUIHandler에 구현되어 있는데
MS에서 찾아보니
mshtmhst.h에 선언 되어 있답니다.
관련내용
It is declared in mshtmhst.h. If you download the headerfiles from MS
mshtmhst.idl is also included. You can try cut and paste it to the text
window in type library editor and see if it works.It is declared in mshtmhst.h. If you download the headerfiles from MS
mshtmhst.idl is also included. You can try cut and paste it to the text
window in type library editor and see if it works.
MSDN에서의 내용
http://msdn.microsoft.com/workshop/browser/Hosting/reference/IFaces/IDocHostUIHandler/ShowContextMenu.asp
IDocHostUIHandler::ShowContextMenu Method
--------------------------------------------------------------------------------
Called from MSHTML to display a context menu.
Syntax
HRESULT ShowContextMenu(
DWORD dwID,
POINT FAR *ppt,
IUnknown FAR *pcmdTarget,
IDispatch FAR *pdispObject
);
Parameters
dwID
Identifier of the context menu to be displayed.
ppt
POINT structure containing the screen coordinates for the menu.
pcmdTarget
Address of an IOleCommandTarget interface used to query command status and execute commands on this object.
pdispObject
Address of an IDispatch interface of the object at the screen coordinates specified in ppt. This allows a host to differentiate particular objects to provide more specific context.
Return Value
Returns one of the following values:
S_OK Host displayed its own UI. MSHTML will not attempt to display its UI.
S_FALSE Host did not display any UI. MSHTML will display its UI.
DOCHOST_E_UNKNOWN Menu identifier is unknown. MSHTML may attempt an alternative identifier from a previous version.
Remarks
In Microsoft® Internet Explorer 4.0 the pdispObject parameter supplied no information, but in Internet Explorer 5 and later the parameter contains the address of an IDispatch interface.
Windows CE
Windows CE Use version 2.12 and later
Minimum availability Internet Explorer 4.0
Example
The following code example shows how the pdispObject parameter is used.
IHTMLElement *pElem;
HRESULT hr;
hr = pdispObject->QueryInterface(IID_IHTMLElement, (void**)pElem);
if(SUCCEEDED (hr))
{
BSTR bstr;
pElem->get_tagName(bstr);
USES_CONVERSION;
ATLTRACE("TagName:%sn", OLE2T(bstr));
SysFreeString(bstr);
pElem->Release();
}
IDocHostUIHandler::ShowContextMenu Method
--------------------------------------------------------------------------------
Called from MSHTML to display a context menu.
Syntax
HRESULT ShowContextMenu(
DWORD dwID,
POINT FAR *ppt,
IUnknown FAR *pcmdTarget,
IDispatch FAR *pdispObject
);
Parameters
dwID
Identifier of the context menu to be displayed.
ppt
POINT structure containing the screen coordinates for the menu.
pcmdTarget
Address of an IOleCommandTarget interface used to query command status and execute commands on this object.
pdispObject
Address of an IDispatch interface of the object at the screen coordinates specified in ppt. This allows a host to differentiate particular objects to provide more specific context.
Return Value
Returns one of the following values:
S_OK Host displayed its own UI. MSHTML will not attempt to display its UI.
S_FALSE Host did not display any UI. MSHTML will display its UI.
DOCHOST_E_UNKNOWN Menu identifier is unknown. MSHTML may attempt an alternative identifier from a previous version.
Remarks
In Microsoft® Internet Explorer 4.0 the pdispObject parameter supplied no information, but in Internet Explorer 5 and later the parameter contains the address of an IDispatch interface.
Windows CE
Windows CE Use version 2.12 and later
Minimum availability Internet Explorer 4.0
Example
The following code example shows how the pdispObject parameter is used.
IHTMLElement *pElem;
HRESULT hr;
hr = pdispObject->QueryInterface(IID_IHTMLElement, (void**)pElem);
if(SUCCEEDED (hr))
{
BSTR bstr;
pElem->get_tagName(bstr);
USES_CONVERSION;
ATLTRACE("TagName:%sn", OLE2T(bstr));
SysFreeString(bstr);
pElem->Release();
}
프로그램에서 IDocHostUIHandler의 ShowContextMenu를 사용하려면
어떻게 해야 하나요?