1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +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

@ -8,8 +8,7 @@
<Unit0>
<Filename Value="JSSimpleWindowBinding.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<TopLine Value="52"/>
<TopLine Value="44"/>
<CursorPos Y="68"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
@ -21,16 +20,17 @@
<ComponentName Value="JSSimpleWindowBindingFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="77"/>
<CursorPos X="39" Y="134"/>
<TopLine Value="175"/>
<CursorPos X="22" Y="207"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit1>
</Units>
<JumpHistory Count="2" HistoryIndex="1">
<JumpHistory Count="4" HistoryIndex="3">
<Position1>
<Filename Value="uJSSimpleWindowBinding.pas"/>
</Position1>
@ -38,6 +38,14 @@
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="75" Column="43" TopLine="55"/>
</Position2>
<Position3>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="117" Column="82" TopLine="101"/>
</Position3>
<Position4>
<Filename Value="uJSSimpleWindowBinding.pas"/>
<Caret Line="122" Column="82" TopLine="106"/>
</Position4>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@ -14,7 +14,7 @@ object JSSimpleWindowBindingFrm: TJSSimpleWindowBindingFrm
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.0.2.0'
LCLVersion = '2.0.4.0'
object NavControlPnl: TPanel
Left = 0
Height = 21
@ -69,4 +69,9 @@ object JSSimpleWindowBindingFrm: TJSSimpleWindowBindingFrm
left = 32
top = 288
end
object CEFSentinel1: TCEFSentinel
OnClose = CEFSentinel1Close
left = 32
top = 352
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);
@ -113,7 +118,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 TJSSimpleWindowBindingFrm.GoBtnClick(Sender: TObject);
begin
@ -146,6 +152,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;
@ -192,8 +204,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(