How to disable right click in WebBrowser when we're using Flash ! (Delphi)
How can i disable the menu of flash player when I'm navigating a flash f开发者_高级运维ile with WebBrowser ?
All messages that are sent to the WebBrowser, pass through your Delphi application as well, so by using a TApplicationEvents component and checking for the right-click event in the OnMessage event on the Handle of WebBrowser, or any of it's child handles (use IsChild) and set Handled, you should be able to block it.
The code could look like this
procedure TMyForm.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (Msg.message=WM_RBUTTONDOWN) and IsChild(WebBrowser1.Handle,Msg.hwnd) then
begin
PopupMenu1.Popup(Msg.pt.X,Msg.pt.Y);
Handled:=true;
end;
end;
Heres another way.
procedure TForm1.FormMouseActivate(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y, HitTest: Integer;
var MouseActivate: TMouseActivate);
begin
if Button=mbRight then
begin
if (x >= WebBrowser1.Left) and
(x <= WebBrowser1.Left + WebBrowser1.Width ) and
(y >= WebBrowser1.Top) and
(y <= WebBrowser1.Top + WebBrowser1.Height ) then
MouseActivate := maNoActivateAndEat;
end;
end;
精彩评论