4

How can i disable the menu of flash player when I'm navigating a flash file with WebBrowser ?

ahsteele
  • 26,243
  • 28
  • 134
  • 248
Kermia
  • 4,171
  • 13
  • 64
  • 105

2 Answers2

4

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;
Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
1

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;