加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

inno-setup – 禁用Chromium Embedded 3(DCEF3)中的上下文菜单

发布时间:2020-12-15 04:16:19 所属栏目:大数据 来源:网络整理
导读:我正在尝试在Chromium Embedded(DCEF3)的窗口中禁用鼠标右键(上下文菜单),但我没有得到,我没有找到任何设置来本机执行此操作. 我可以禁用“查看源代码”,我正在使用下面的代码,但我真的想要禁用上下文菜单,或者不希望它出现. 注意:我在DLL“Chromium.dll”
我正在尝试在Chromium Embedded(DCEF3)的窗口中禁用鼠标右键(上下文菜单),但我没有得到,我没有找到任何设置来本机执行此操作.

我可以禁用“查看源代码”,我正在使用下面的代码,但我真的想要禁用上下文菜单,或者不希望它出现.

注意:我在DLL“Chromium.dll”中使用这个libray与“Inno Setup”一起使用,等同于Inno Web Brower.

procedure TInnoChromium.OnContextMenuCommand(Sender: TObject;
  const browser: ICefBrowser; const frame: ICefFrame;
  const params: ICefContextMenuParams; commandId: Integer;
  eventFlags: TCefEventFlags; out Result: Boolean);
begin
if (commandId = 132) then Result := True; // MENU_ID_VIEW_SOURCE
end;

解决方法

要禁用DCEF 3中的上下文菜单,您需要处理 OnBeforeContextMenu事件并清除其模型参数.这就是参考文献所指出的内容(我强调):

OnBeforeContextMenu

Called before a context menu is displayed. |params| provides
information about the context menu state. |model| initially contains
the default context menu. The |model| can be cleared to show no
context menu
or modified to show a custom menu. Do not keep
references to |params| or |model| outside of this callback.

因此,要完全禁用上下文菜单,您将编写如下内容:

uses
  cefvcl,ceflib;

type
  TInnoChromium = class
  ...
  private
    FChromium: TChromium;
    procedure BeforeContextMenu(Sender: TObject; const browser: ICefBrowser;
      const frame: ICefFrame;
  public
    constructor Create;
  end;

implementation

constructor TInnoChromium.Create;
begin
  FChromium := TChromium.Create(nil);
  ...
  FChromium.OnBeforeContextMenu := BeforeContextMenu;
end;

procedure TInnoChromium.BeforeContextMenu(Sender: TObject; const browser: ICefBrowser;
  const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel);
begin
  // to disable the context menu clear the model parameter
  model.Clear;
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读