如何去掉webbrowser控件在显示网页时的右键菜单(0分)

C

cgqok

Unregistered / Unconfirmed
GUEST, unregistred user!
用webbrowser显示网页时,单击网页右键会出现一个右键菜单,能不能设置成单击鼠标右键不出现菜单呢
 
S

sunnyfairy

Unregistered / Unconfirmed
GUEST, unregistred user!
onpopup....中写Handled := False;
不知道行不行!手上没有 Delphi;
你那么多分都不知道弄点出来!
 
S

satanmonkey

Unregistered / Unconfirmed
GUEST, unregistred user!
要屏蔽掉右键菜单,只要实现IDocHostUIHandler.ShowContexMenu返回S_OK就可以了,你必须自己实现这个接口,另外你还必须使用ICustomDoc接口,用这个接口的SetUIHandler来设置Document的IDocHostUIHandler
这2个接口delphi自己没带,我翻译c++的如下
IDocHostUIHandler = interface(IUnknown)
['{bd3f23c0-d43e-11cf-893b-00aa00bdce1a}']
function ShowContextMenu(const dwID: DWORD;
const ppt: PPOINT;
const pcmdtReserved: IUnknown;
const pdispReserved: IDispatch): HRESULT;
stdcall;
function GetHostInfo(var pInfo: TDOCHOSTUIINFO): HRESULT;
stdcall;
function ShowUI(const dwID: DWORD;
const pActiveObject: IOleInPlaceActiveObject;
const pCommandTarget: IOleCommandTarget;
const pFrame: IOleInPlaceFrame;
const pDoc: IOleInPlaceUIWindow): HRESULT;
stdcall;
function HideUI: HRESULT;
stdcall;
function UpdateUI: HRESULT;
stdcall;
function EnableModeless(const fEnable: BOOL): HRESULT;
stdcall;
function OnDocWindowActivate(const fActivate: BOOL): HRESULT;
stdcall;
function OnFrameWindowActivate(const fActivate: BOOL): HRESULT;
stdcall;
function ResizeBorder(const prcBorder: PRECT;
const pUIWindow: IOleInPlaceUIWindow;
const fRameWindow: BOOL): HRESULT;
stdcall;
function TranslateAccelerator(const lpMsg: PMSG;
const pguidCmdGroup: PGUID;
const nCmdID: DWORD): HRESULT;
stdcall;
function GetOptionKeyPath(var pchKey: POLESTR;
const dw: DWORD): HRESULT;
stdcall;
function GetDropTarget(const pDropTarget: IDropTarget;
out ppDropTarget: IDropTarget): HRESULT;
stdcall;
function GetExternal(out ppDispatch: IDispatch): HRESULT;
stdcall;
function TranslateUrl(const dwTranslate: DWORD;
const pchURLIn: POLESTR;
var ppchURLOut: POLESTR): HRESULT;
stdcall;
function FilterDataObject(const pDO: IDataObject;
out ppDORet: IDataObject): HRESULT;
stdcall;

end;

ICustomDoc=interface(IUnknown)
['{3050f3f0-98b5-11cf-bb82-00aa00bdce0b}']
function SetUIHandler(const pUIHandler:IDocHostUIHandler):HRESULT;
stdcall;
end;


另外一个方法就是hook
 
Z

zlkxzy

Unregistered / Unconfirmed
GUEST, unregistred user!
你要是没有分,我们也不要,可你有那么多分,为什么不出一点呢,
你这么小气,我们也不能大气了,告诉你一点就是给web这个控件发一个消息屏蔽掉右键就行了.呵呵,很简单,就三两行代码
 
S

satanmonkey

Unregistered / Unconfirmed
GUEST, unregistred user!
居然是个0分帖.回复的时侯没发现.
 
L

liyinwei

Unregistered / Unconfirmed
GUEST, unregistred user!
0分贴?我也进来凑凑热闹,这个问题我以前也碰过,确实只要3行代码就解决了。
 
C

cgqok

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
顶部