Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 file with WebBrowser ?

like image 293
Kermia Avatar asked Oct 15 '25 23:10

Kermia


2 Answers

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;
like image 82
Stijn Sanders Avatar answered Oct 17 '25 18:10

Stijn Sanders


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;
like image 23
Serkan Ekşioğlu Avatar answered Oct 17 '25 17:10

Serkan Ekşioğlu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!