1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-12-03 21:44:45 +02:00

Fixed the CustomResourceHandler demo

- Added TCEFSentinel to more demos
This commit is contained in:
Salvador Díaz Fau
2019-10-14 15:39:27 +02:00
parent 77121dc510
commit 4d994de2e9
99 changed files with 1179 additions and 512 deletions

View File

@@ -22,8 +22,8 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="149"/>
<CursorPos Y="153"/>
<TopLine Value="109"/>
<CursorPos X="77" Y="130"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@@ -56,7 +56,7 @@
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit4>
</Units>
<JumpHistory Count="12" HistoryIndex="11">
<JumpHistory Count="14" HistoryIndex="13">
<Position1>
<Filename Value="uJSExtensionWithFunction.pas"/>
</Position1>
@@ -104,6 +104,14 @@
<Filename Value="uJSExtensionWithFunction.pas"/>
<Caret Line="105" Column="11" TopLine="89"/>
</Position12>
<Position13>
<Filename Value="uJSExtensionWithFunction.pas"/>
<Caret Line="168" TopLine="149"/>
</Position13>
<Position14>
<Filename Value="uJSExtensionWithFunction.pas"/>
<Caret Line="173" TopLine="154"/>
</Position14>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@@ -80,4 +80,9 @@ object JSExtensionWithFunctionFrm: TJSExtensionWithFunctionFrm
left = 32
top = 288
end
object CEFSentinel1: TCEFSentinel
OnClose = CEFSentinel1Close
left = 32
top = 360
end
end

View File

@@ -52,10 +52,14 @@ uses
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants,
uCEFWinControl;
uCEFWinControl, uCEFSentinel;
type
{ TJSExtensionWithFunctionFrm }
TJSExtensionWithFunctionFrm = class(TForm)
CEFSentinel1: TCEFSentinel;
NavControlPnl: TPanel;
Edit1: TEdit;
GoBtn: TButton;
@@ -63,6 +67,7 @@ type
Chromium1: TChromium;
Timer1: TTimer;
StatusBar1: TStatusBar;
procedure CEFSentinel1Close(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
@@ -121,7 +126,8 @@ uses
// =================
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
// 3. TChromium.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
procedure GlobalCEFApp_OnWebKitInitializedEvent;
var
@@ -165,8 +171,7 @@ end;
procedure TJSExtensionWithFunctionFrm.Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
CEFSentinel1.Start;
end;
procedure TJSExtensionWithFunctionFrm.Chromium1BeforePopup(Sender: TObject;
@@ -228,6 +233,12 @@ begin
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSExtensionWithFunctionFrm.CEFSentinel1Close(Sender: TObject);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TJSExtensionWithFunctionFrm.WMMove(var aMessage : TWMMove);
begin
inherited;