Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 铬嵌入式框架_C++_Delphi_Chromium_Chromium Embedded - Fatal编程技术网

C++ 铬嵌入式框架

C++ 铬嵌入式框架,c++,delphi,chromium,chromium-embedded,C++,Delphi,Chromium,Chromium Embedded,如何以相同的形式真正打开新的选项卡,使用选项卡或简单地使用相同的cef组件或创建新的选项卡,这不是重要的部分。 重要的是它的用途是什么 procedure OnBeforePopup ... ... begin Return:= true; TChromium1.LoadURL(target_url); end; 在某些情况下不起作用,比如在real browser中,我认为这并不是真正的分派到新选项卡 在TWebBrowser中,我没有这样的问题,代码运行良好: pro

如何以相同的形式真正打开新的选项卡,使用选项卡或简单地使用相同的cef组件或创建新的选项卡,这不是重要的部分。 重要的是它的用途是什么

procedure OnBeforePopup ...
  ...
  begin
  Return:= true;
  TChromium1.LoadURL(target_url);
end; 
在某些情况下不起作用,比如在real browser中,我认为这并不是真正的分派到新选项卡

在TWebBrowser中,我没有这样的问题,代码运行良好:

  procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
  var ppDisp: IDispatch; var Cancel: WordBool);
  var NewWindow: TForm1;
  begin
    NewWindow := TForm1.Create(self);
    NewWindow.Show;
   ppDisp := NewWindow.Webbrowser1.DefaultDispatch;
  end;
如何进行真正的调度

OnBeforePopup中存在常量目标\u处置。
如何将目标配置更改为当前选项卡?

您为更好的浏览器付出的代价是花更多时间尝试将其嵌入应用程序。 一般来说,从开发人员的角度来看,TWebBrowser组件更易于使用,但您的用户会有更糟糕的体验

使用CEF以正确的方式打开新的选项卡或表单是更复杂的功能之一

这就是我在和中添加演示的原因

不能更改常量参数。我建议您按照CEF3关于此事件的说明创建一个新的子浏览器

OnBeforePopup事件的CEF3代码注释如下:

///
// Called on the UI thread before a new popup browser is created. The
// |browser| and |frame| values represent the source of the popup request. The
// |target_url| and |target_frame_name| values indicate where the popup
// browser should navigate and may be NULL if not specified with the request.
// The |target_disposition| value indicates where the user intended to open
// the popup (e.g. current tab, new tab, etc). The |user_gesture| value will
// be true (1) if the popup was opened via explicit user gesture (e.g.
// clicking a link) or false (0) if the popup opened automatically (e.g. via
// the DomContentLoaded event). The |popupFeatures| structure contains
// additional information about the requested popup window. To allow creation
// of the popup browser optionally modify |windowInfo|, |client|, |settings|
// and |no_javascript_access| and return false (0). To cancel creation of the
// popup browser return true (1). The |client| and |settings| values will
// default to the source browser's values. If the |no_javascript_access| value
// is set to false (0) the new browser will not be scriptable and may not be
// hosted in the same renderer process as the source browser. Any
// modifications to |windowInfo| will be ignored if the parent browser is
// wrapped in a cef_browser_view_t. Popup browser creation will be canceled if
// the parent browser is destroyed before the popup browser creation completes
// (indicated by a call to OnAfterCreated for the popup browser).
///
这里的挑战是CEF3可能使用与主线程不同的线程来执行所有事件,并且您希望在触发此事件时创建VCL组件

如果在CEF.inc中设置CEF_多线程消息_循环,DCEF3将使用不同的线程。 如果GlobalCEFApp.multi-threadedMessageLoop为True,则CEF4Delphi使用不同的线程,这是默认值,因为它是CEF3为Windows应用程序推荐的设置

如您所知,如果您在不同的线程中创建和销毁VCL组件,您将遇到问题

这迫使您创建一个隐藏的弹出窗体,以防触发此事件。正如您在PopupBrowser2中所看到的,有一个隐藏的FChildForm,它是在主线程中和该事件外部创建的

稍后,当OnBeforePopup执行时,演示程序调用CreateClientHandler,使用FChildForm使用的windowInfo和client设置windowInfo和client事件参数

如果要使用选项卡,还需要创建隐藏选项卡

您还可以尝试在DCEF3中取消设置CEF_多线程消息_循环,或在CEF4Delphi中将GlobalCEFApp.MULTI-threadedMessageLoop设置为False,但随后需要使用外部泵。有关更多详细信息,请参阅SimpleExternalPumpBrowser演示