1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +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="174"/>
<CursorPos X="74" Y="179"/>
<TopLine Value="194"/>
<CursorPos X="22" Y="200"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@@ -53,7 +53,7 @@
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit4>
</Units>
<JumpHistory Count="9" HistoryIndex="8">
<JumpHistory Count="11" HistoryIndex="10">
<Position1>
<Filename Value="uJSExecutingFunctions.pas"/>
</Position1>
@@ -89,6 +89,14 @@
<Filename Value="uJSExecutingFunctions.pas"/>
<Caret Line="116" Column="11" TopLine="100"/>
</Position9>
<Position10>
<Filename Value="uJSExecutingFunctions.pas"/>
<Caret Line="140" Column="82" TopLine="138"/>
</Position10>
<Position11>
<Filename Value="uJSExecutingFunctions.pas"/>
<Caret Line="145" Column="82" TopLine="143"/>
</Position11>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@@ -72,4 +72,9 @@ object JSExecutingFunctionsFrm: TJSExecutingFunctionsFrm
left = 32
top = 288
end
object CEFSentinel1: TCEFSentinel
OnClose = CEFSentinel1Close
left = 32
top = 352
end
end

View File

@@ -52,7 +52,7 @@ uses
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes,
uCEFConstants, uCEFv8Value, uCEFWinControl;
uCEFConstants, uCEFv8Value, uCEFWinControl, uCEFSentinel;
const
JSDEMO_CONTEXTMENU_EXECFUNCTION = MENU_ID_USER_FIRST + 1;
@@ -60,13 +60,18 @@ const
EXECFUNCTION_MSGNAME = 'execfunction';
type
{ TJSExecutingFunctionsFrm }
TJSExecutingFunctionsFrm = 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);
@@ -136,7 +141,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.
uses
uCEFProcessMessage, uMyV8Handler;
@@ -191,8 +197,7 @@ end;
procedure TJSExecutingFunctionsFrm.Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
CEFSentinel1.Start;
end;
procedure TJSExecutingFunctionsFrm.Chromium1BeforeContextMenu(
@@ -273,6 +278,12 @@ begin
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSExecutingFunctionsFrm.CEFSentinel1Close(Sender: TObject);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TJSExecutingFunctionsFrm.WMMove(var aMessage : TWMMove);
begin
inherited;