Skip to content

Commit

Permalink
Fixed issue #202
Browse files Browse the repository at this point in the history
- Updated the OnBeforeClose event in all demos using TChromiumWindow to send a WM_CLOSE message instead of calling "close".
- Fixed all MDI demos. Now the demo will not close automatically when the last browser is closed manually.
  • Loading branch information
salvadordf committed Jul 10, 2019
1 parent 5d36c42 commit 0e08d66
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/CustomResourceBrowser/uMainForm.pas
Expand Up @@ -182,7 +182,7 @@ procedure TMainForm.Timer1Timer(Sender: TObject);
procedure TMainForm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TMainForm.ChromiumWindow1Close(Sender: TObject);
Expand Down
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/DLLBrowser/uWebBrowser.pas
Expand Up @@ -160,7 +160,7 @@ procedure TWebBrowserFrm.Timer1Timer(Sender: TObject);
procedure TWebBrowserFrm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TWebBrowserFrm.ChromiumWindow1Close(Sender: TObject);
Expand Down
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/JavaScript/JSDialog/uJSDialogBrowser.pas
Expand Up @@ -240,7 +240,7 @@ procedure TJSDialogBrowserFrm.Chromium_OnJsdialog(Sender : TObject;
procedure TJSDialogBrowserFrm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TJSDialogBrowserFrm.ChromiumWindow1Close(Sender: TObject);
Expand Down
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/MDIBrowser/uMainForm.pas
Expand Up @@ -184,7 +184,7 @@ procedure TMainForm.ExitBtnClick(Sender: TObject);
procedure TMainForm.ChildDestroyedMsg(var aMessage : TMessage);
begin
// If there are no more child forms we can destroy the main form
if (MDIChildCount = 0) then
if FClosing and (MDIChildCount = 0) then
begin
ButtonPnl.Enabled := False;
FCanClose := True;
Expand Down
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/MDIExternalPumpBrowser/uMainForm.pas
Expand Up @@ -195,7 +195,7 @@ procedure TMainForm.ExitBtnClick(Sender: TObject);
procedure TMainForm.ChildDestroyedMsg(var aMessage : TMessage);
begin
// If there are no more child forms we can destroy the main form
if (MDIChildCount = 0) then
if FClosing and (MDIChildCount = 0) then
begin
ButtonPnl.Enabled := False;
FCanClose := True;
Expand Down
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/SimpleBrowser/uSimpleBrowser.pas
Expand Up @@ -150,7 +150,7 @@ procedure TForm1.FormShow(Sender: TObject);
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TForm1.ChromiumWindow1Close(Sender: TObject);
Expand Down
Expand Up @@ -175,7 +175,7 @@ procedure TSimpleExternalPumpBrowserFrm.ChromiumWindow1AfterCreated(Sender: TObj
procedure TSimpleExternalPumpBrowserFrm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TSimpleExternalPumpBrowserFrm.ChromiumWindow1Close(Sender: TObject);
Expand Down
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/SubProcess/uSimpleBrowser.pas
Expand Up @@ -157,7 +157,7 @@ procedure TForm1.ChromiumWindow1Close(Sender: TObject);
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TForm1.Chromium_OnBeforePopup(Sender: TObject;
Expand Down
14 changes: 9 additions & 5 deletions demos/Lazarus/CustomResourceBrowser/CRBrowser.lps
Expand Up @@ -8,9 +8,8 @@
<Unit0>
<Filename Value="CRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<TopLine Value="40"/>
<CursorPos X="10" Y="71"/>
<CursorPos X="61" Y="62"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
Expand All @@ -21,9 +20,10 @@
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="89"/>
<CursorPos Y="106"/>
<TopLine Value="166"/>
<CursorPos Y="169"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand Down Expand Up @@ -71,7 +71,7 @@
<Loaded Value="True"/>
</Unit6>
</Units>
<JumpHistory Count="13" HistoryIndex="12">
<JumpHistory Count="14" HistoryIndex="13">
<Position1>
<Filename Value="uMainForm.pas"/>
</Position1>
Expand Down Expand Up @@ -123,6 +123,10 @@
<Filename Value="uMainForm.pas"/>
<Caret Line="117" Column="69" TopLine="109"/>
</Position13>
<Position14>
<Filename Value="uMainForm.pas"/>
<Caret Line="73" Column="30" TopLine="59"/>
</Position14>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
Expand Down
4 changes: 2 additions & 2 deletions demos/Lazarus/CustomResourceBrowser/uMainForm.lfm
@@ -1,7 +1,7 @@
object MainForm: TMainForm
Left = 150
Left = 386
Height = 658
Top = 86
Top = 91
Width = 781
Caption = 'Custom Resource Browser'
ClientHeight = 658
Expand Down
2 changes: 1 addition & 1 deletion demos/Lazarus/CustomResourceBrowser/uMainForm.pas
Expand Up @@ -166,7 +166,7 @@ procedure TMainForm.Timer1Timer(Sender: TObject);
procedure TMainForm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TMainForm.ChromiumWindow1Close(Sender: TObject);
Expand Down
10 changes: 7 additions & 3 deletions demos/Lazarus/JavaScript/JSDialog/JSDialogBrowser.lps
Expand Up @@ -22,15 +22,15 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="107"/>
<CursorPos X="40" Y="105"/>
<TopLine Value="247"/>
<CursorPos X="41" Y="251"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit1>
</Units>
<JumpHistory Count="4" HistoryIndex="3">
<JumpHistory Count="5" HistoryIndex="4">
<Position1>
<Filename Value="JSDialogBrowser.lpr"/>
</Position1>
Expand All @@ -46,6 +46,10 @@
<Filename Value="uJSDialogBrowser.pas"/>
<Caret Line="88" Column="386" TopLine="70"/>
</Position4>
<Position5>
<Filename Value="uJSDialogBrowser.pas"/>
<Caret Line="72" Column="32" TopLine="64"/>
</Position5>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
Expand Down
2 changes: 1 addition & 1 deletion demos/Lazarus/JavaScript/JSDialog/uJSDialogBrowser.pas
Expand Up @@ -248,7 +248,7 @@ procedure TJSDialogBrowserFrm.Chromium_OnJsdialog(Sender : TObject;
procedure TJSDialogBrowserFrm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TJSDialogBrowserFrm.ChromiumWindow1Close(Sender: TObject);
Expand Down
4 changes: 2 additions & 2 deletions demos/Lazarus/SimpleBrowser/SimpleBrowser.lps
Expand Up @@ -22,8 +22,8 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="135"/>
<CursorPos X="64" Y="129"/>
<TopLine Value="149"/>
<CursorPos X="41" Y="170"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand Down
2 changes: 1 addition & 1 deletion demos/Lazarus/SimpleBrowser/uSimpleBrowser.pas
Expand Up @@ -167,7 +167,7 @@ procedure TForm1.FormShow(Sender: TObject);
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TForm1.ChromiumWindow1Close(Sender: TObject);
Expand Down
Expand Up @@ -22,8 +22,8 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="111"/>
<CursorPos X="41" Y="122"/>
<TopLine Value="150"/>
<CursorPos X="41" Y="179"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand Down
Expand Up @@ -176,7 +176,7 @@ procedure TSimpleExternalPumpBrowserFrm.ChromiumWindow1AfterCreated(Sender: TObj
procedure TSimpleExternalPumpBrowserFrm.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TSimpleExternalPumpBrowserFrm.ChromiumWindow1Close(Sender: TObject);
Expand Down
8 changes: 4 additions & 4 deletions demos/Lazarus/SubProcess/SimpleBrowser.lps
Expand Up @@ -20,9 +20,10 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="75"/>
<CursorPos X="39" Y="169"/>
<TopLine Value="147"/>
<CursorPos X="41" Y="160"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand All @@ -31,9 +32,8 @@
<Unit2>
<Filename Value="uCEFLoader.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="51"/>
<TopLine Value="36"/>
<CursorPos Y="65"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
Expand Down
2 changes: 1 addition & 1 deletion demos/Lazarus/SubProcess/uSimpleBrowser.pas
Expand Up @@ -157,7 +157,7 @@ procedure TForm1.ChromiumWindow1Close(Sender: TObject);
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
begin
FCanClose := True;
Close;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;

procedure TForm1.Chromium_OnBeforePopup(Sender: TObject;
Expand Down
10 changes: 1 addition & 9 deletions source/uCEFChromiumWindow.pas
Expand Up @@ -78,7 +78,6 @@ TChromiumWindow = class(TCEFWinControl)
procedure WndProc(var aMessage: TMessage); override;

procedure OnCloseMsg(var aMessage : TMessage); message CEF_DOONCLOSE;
procedure OnBeforeCloseMsg(var aMessage : TMessage); message CEF_DOONBEFORECLOSE;
procedure OnAfterCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
{$ENDIF}
procedure WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
Expand Down Expand Up @@ -203,9 +202,7 @@ procedure TChromiumWindow.WebBrowser_OnClose(Sender: TObject; const browser: ICe

procedure TChromiumWindow.WebBrowser_OnBeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
{$IFDEF MSWINDOWS}
if assigned(FOnBeforeClose) then PostMessage(Handle, CEF_DOONBEFORECLOSE, 0, 0);
{$ENDIF}
if assigned(FOnBeforeClose) then FOnBeforeClose(self);
end;

procedure TChromiumWindow.WebBrowser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser);
Expand All @@ -221,11 +218,6 @@ procedure TChromiumWindow.OnCloseMsg(var aMessage : TMessage);
if assigned(FOnClose) then FOnClose(self);
end;

procedure TChromiumWindow.OnBeforeCloseMsg(var aMessage : TMessage);
begin
if assigned(FOnBeforeClose) then FOnBeforeClose(self);
end;

procedure TChromiumWindow.OnAfterCreatedMsg(var aMessage : TMessage);
begin
UpdateSize;
Expand Down
4 changes: 2 additions & 2 deletions update_CEF4Delphi.json
@@ -1,8 +1,8 @@
{
"UpdateLazPackages" : [
{
"ForceNotify" : false,
"InternalVersion" : 14,
"ForceNotify" : true,
"InternalVersion" : 15,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "75.0.13.0"
}
Expand Down

0 comments on commit 0e08d66

Please sign in to comment.