D3F*_*ULT 7 inno-setup chromium-embedded
我试图在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;
Run Code Online (Sandbox Code Playgroud)
TLa*_*ama 16
要禁用DCEF 3中的上下文菜单,您需要处理OnBeforeContextMenu事件并清除其model参数.这就是参考文献所指出的内容(我强调):
OnBeforeContextMenu
在显示上下文菜单之前调用.| PARAMS | 提供有关上下文菜单状态的信息.|模型| 最初包含默认上下文菜单.|模型| 可以清除以显示上下文菜单或修改为显示自定义菜单.不要保留对| params |的引用 或者|模特| 在这个回调之外.
因此,要完全禁用上下文菜单,您将编写如下内容:
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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5737 次 |
| 最近记录: |