当我使用 WebBrowser 浏览 Flash 文件时,如何禁用 Flash Player 的菜单?
问问题
3724 次
2 回答
4
发送到 WebBrowser 的所有消息也通过您的 Delphi 应用程序,因此通过使用 TApplicationEvents 组件并检查 WebBrowser 的句柄上的 OnMessage 事件中的右键单击事件,或者它的任何子句柄(使用IsChild ) 并设置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;
于 2010-11-20T21:16:33.273 回答
0
这是另一种方式。
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;
于 2020-07-29T10:58:22.620 回答