如何屏蔽TWebBrowser的右键菜单 public { Public declarations } procedure OnAppMsg(var msg: tmsg;var handled: boolean);procedure TForm1.FormCreate(Sender: TObject); begin WebBrowser1.Navigate('http://www.163.com'); Application.OnMessage := OnAppMsg; end;procedure TForm1.OnAppMsg(var msg: tmsg; var handled: boolean); begin if (msg.message = wm_rbuttondown) then begin showmessage(inttostr(WebBrowser1.Handle)); //showmessage(inttostr(windowfrompoint(ScreenToClient(msg.pt)))); // showmessage(inttostr(msg.lParam)); //showmessage(inttostr(longint(@msg.wParam))); showmessage('trap browser mouse'); end else inherited; end;
public
{ Public declarations }
procedure OnAppMsg(var msg: tmsg;var handled: boolean);procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.163.com');
Application.OnMessage := OnAppMsg;
end;procedure TForm1.OnAppMsg(var msg: tmsg; var handled: boolean);
begin
if (msg.message = wm_rbuttondown) then
begin
showmessage(inttostr(WebBrowser1.Handle));
//showmessage(inttostr(windowfrompoint(ScreenToClient(msg.pt))));
// showmessage(inttostr(msg.lParam));
//showmessage(inttostr(longint(@msg.wParam)));
showmessage('trap browser mouse');
end
else
inherited;
end;
IDocHostUIHandler::ShowContextMenu
通过实现这一个方法, 你获得在当一个用户右击时被浏览器控件显示的快捷菜单的控制。你能通过在这个方法中返回S_OK 阻止IE显示它的默认快捷菜单。返回一些其他的数值 , 像S_FALSE或E_NOTIMPL,允许IE继续执行它的默认快捷菜单行为。如果你仅仅在这个方法中返回S_OK, 你能避免任何浏览器控件的右击行为。 这可能是你在许多场合中的全部需求,但是你能做到更多。通常,你使用这一个方法在返回 S_OK 之前产生并且显示你自己的快捷菜单。如果你知道浏览器控件显示的菜单的资源,而且它如何选择他们,你能也有效地自定义默认的浏览器控件快捷菜单。让我们看看它如何工作。……