如何在使用Flash时禁用WebBrowser中的右键单击!(Delphi)

4

我在使用WebBrowser浏览Flash文件时,如何禁用Flash播放器的菜单?

2个回答

4
所有发送给WebBrowser的消息都会通过您的Delphi应用程序传递,因此通过使用TApplicationEvents组件,在WebBrowser的Handle或任何其子句柄(使用IsChild)的OnMessage事件中检查右键单击事件并设置Handled,您应该能够阻止它。
代码可能如下所示:
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;

谢谢您的回复,您能给我一个例子吗? - Kermia

1
这是另一种方法。
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;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接