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,15 +22,15 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="110"/>
<CursorPos Y="135"/>
<TopLine Value="223"/>
<CursorPos X="22" Y="226"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit1>
</Units>
<JumpHistory Count="8" HistoryIndex="7">
<JumpHistory Count="15" HistoryIndex="14">
<Position1>
<Filename Value="uJSSimpleWindowBinding.pas"/>
</Position1>
@@ -62,6 +62,34 @@
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="158" Column="3" TopLine="147"/>
</Position8>
<Position9>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="118" Column="82" TopLine="110"/>
</Position9>
<Position10>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="123" Column="82" TopLine="115"/>
</Position10>
<Position11>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="159" Column="50" TopLine="141"/>
</Position11>
<Position12>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="86" Column="15" TopLine="59"/>
</Position12>
<Position13>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="225" TopLine="222"/>
</Position13>
<Position14>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="177" Column="47" TopLine="165"/>
</Position14>
<Position15>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="86" Column="15" TopLine="50"/>
</Position15>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@@ -69,4 +69,9 @@ object JSSimpleWindowBindingFrm: TJSSimpleWindowBindingFrm
left = 32
top = 288
end
object CEFSentinel1: TCEFSentinel
OnClose = CEFSentinel1Close
left = 32
top = 360
end
end

View File

@@ -52,16 +52,21 @@ uses
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes,
uCEFConstants, uCEFv8Value, uCEFWinControl;
uCEFConstants, uCEFv8Value, uCEFWinControl, uCEFSentinel;
type
{ TJSSimpleWindowBindingFrm }
TJSSimpleWindowBindingFrm = class(TForm)
CEFSentinel1: TCEFSentinel;
NavControlPnl: TPanel;
Edit1: TEdit;
GoBtn: TButton;
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
Timer1: TTimer;
procedure CEFSentinel1Close(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
@@ -114,7 +119,8 @@ implementation
// =================
// 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 form.
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
var
@@ -165,6 +171,12 @@ begin
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSSimpleWindowBindingFrm.CEFSentinel1Close(Sender: TObject);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TJSSimpleWindowBindingFrm.WMMove(var aMessage : TWMMove);
begin
inherited;
@@ -211,8 +223,7 @@ end;
procedure TJSSimpleWindowBindingFrm.Chromium1BeforeClose(
Sender: TObject; const browser: ICefBrowser);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
CEFSentinel1.Start;
end;
procedure TJSSimpleWindowBindingFrm.Chromium1Close(