1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-04 21:32:54 +02:00

Added TCEFSentinel to more demos

- Check that all frames are valid before using them
- Added an error page to MiniBrowser.
This commit is contained in:
Salvador Díaz Fau
2019-10-13 18:50:23 +02:00
parent 9391d68ee0
commit 77121dc510
89 changed files with 1097 additions and 522 deletions

View File

@ -72,4 +72,9 @@ object Form1: TForm1
Left = 56
Top = 88
end
object CEFSentinel1: TCEFSentinel
OnClose = CEFSentinel1Close
Left = 56
Top = 160
end
end

View File

@ -50,7 +50,7 @@ uses
Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces,
uCEFWinControl;
uCEFWinControl, uCEFSentinel;
type
TForm1 = class(TForm)
@ -59,6 +59,7 @@ type
AddressEdt: TEdit;
GoBtn: TButton;
Timer1: TTimer;
CEFSentinel1: TCEFSentinel;
procedure GoBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
@ -70,6 +71,7 @@ type
procedure ChromiumWindow1AfterCreated(Sender: TObject);
procedure ChromiumWindow1Close(Sender: TObject);
procedure ChromiumWindow1BeforeClose(Sender: TObject);
procedure CEFSentinel1Close(Sender: TObject);
private
// You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned.
@ -116,7 +118,8 @@ uses
// =================
// 1. The FormCloseQuery event sets CanClose to False and calls TChromiumWindow.CloseBrowser, which triggers the TChromiumWindow.OnClose event.
// 2. The TChromiumWindow.OnClose event calls TChromiumWindow.DestroyChildWindow which triggers the TChromiumWindow.OnBeforeClose event.
// 3. TChromiumWindow.OnBeforeClose sets FCanClose to True and closes the form.
// 3. TChromiumWindow.OnBeforeClose calls TCEFSentinel.Start, which will trigger TCEFSentinel.OnClose when the renderer processes are closed.
// 4. TCEFSentinel.OnClose sets FCanClose := True and sends WM_CLOSE to the form.
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
@ -151,20 +154,21 @@ begin
if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True;
end;
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
procedure TForm1.CEFSentinel1Close(Sender: TObject);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
begin
CEFSentinel1.Start;
end;
procedure TForm1.ChromiumWindow1Close(Sender: TObject);
begin
// DestroyChildWindow will destroy the child window created by CEF at the top of the Z order.
if not(ChromiumWindow1.DestroyChildWindow) then
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
if not(ChromiumWindow1.DestroyChildWindow) then CEFSentinel1.Start;
end;
procedure TForm1.Chromium_OnBeforePopup( Sender : TObject;