1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-01-23 10:24:51 +02:00

Merge pull request #345 from User4martin/fpc-work-2b

Fix ExternalPumpBrowser, Stop Scheduler.
This commit is contained in:
Salvador Díaz Fau 2021-02-18 18:57:49 +01:00 committed by GitHub
commit b9adf07ac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 10 deletions

View File

@ -38,17 +38,17 @@
(* (*
* Include the following files * Include the following files
* SimpleBrowser2.app/Contents/Frameworks/ExternalPumpBrowser Helper.app/ * ExternalPumpBrowser.app/Contents/Frameworks/ExternalPumpBrowser Helper.app/
* files from the demos/Lazarus_Mac/AppHelper project * files from the demos/Lazarus_Mac/AppHelper project
* use create_mac_helper.sh * use create_mac_helper.sh
* *
* SimpleBrowser2.app/Contents/Frameworks/Chromium Embedded Framework.framework * ExternalPumpBrowser.app/Contents/Frameworks/Chromium Embedded Framework.framework
* files from Release folder in cef download * files from Release folder in cef download
* *
*) *)
program SimpleBrowser2; program ExternalPumpBrowser;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}

View File

@ -42,14 +42,19 @@ unit InitSubProcess;
interface interface
uses uses
GlobalCefApplication, uCEFApplication; GlobalCefApplication, uCEFApplication, uCEFWorkScheduler;
implementation implementation
initialization initialization
CreateGlobalCEFApp; CreateGlobalCEFApp;
if not GlobalCEFApp.StartMainProcess then if not GlobalCEFApp.StartMainProcess then begin
if GlobalCEFWorkScheduler <> nil then
GlobalCEFWorkScheduler.StopScheduler;
DestroyGlobalCEFApp;
DestroyGlobalCEFWorkScheduler;
halt(0); // exit the subprocess halt(0); // exit the subprocess
end;
end. end.

View File

@ -42,10 +42,10 @@ unit uExternalPumpBrowser;
interface interface
uses uses
GlobalCefApplication, GlobalCefApplication, Classes, SysUtils, Messages, Forms, Controls, Graphics,
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, LMessages, Dialogs, ExtCtrls, StdCtrls, LMessages, uCEFChromium, uCEFWindowParent,
uCEFChromium, uCEFWindowParent, uCEFConstants, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFInterfaces, uCEFChromiumEvents,
uCEFChromiumEvents, uCEFLinkedWindowParent, uCEFWorkScheduler; uCEFLinkedWindowParent, uCEFWorkScheduler;
type type
@ -76,7 +76,7 @@ type
procedure GoBtnClick(Sender: TObject); procedure GoBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject); procedure Timer1Timer(Sender: TObject);
private private
protected protected
// Variables to control when can we destroy the form safely // Variables to control when can we destroy the form safely
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
@ -86,6 +86,8 @@ type
procedure WMMove(var Message: TLMMove); message LM_MOVE; procedure WMMove(var Message: TLMMove); message LM_MOVE;
procedure WMSize(var Message: TLMSize); message LM_SIZE; procedure WMSize(var Message: TLMSize); message LM_SIZE;
procedure WMWindowPosChanged(var Message: TLMWindowPosChanged); message LM_WINDOWPOSCHANGED; procedure WMWindowPosChanged(var Message: TLMWindowPosChanged); message LM_WINDOWPOSCHANGED;
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
procedure SendCompMessage(aMsg : cardinal); procedure SendCompMessage(aMsg : cardinal);
@ -273,6 +275,20 @@ begin
Chromium1.NotifyMoveOrResizeStarted; Chromium1.NotifyMoveOrResizeStarted;
end; end;
procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage);
begin
inherited;
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True;
end;
procedure TForm1.WMExitMenuLoop(var aMessage: TMessage);
begin
inherited;
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False;
end;
initialization initialization
if GlobalCEFApp = nil then begin if GlobalCEFApp = nil then begin
CreateGlobalCEFApp; CreateGlobalCEFApp;
@ -284,7 +300,10 @@ initialization
finalization finalization
(* Destroy from this unit, which is used after "Interfaces". So this happens before the Application object is destroyed *) (* Destroy from this unit, which is used after "Interfaces". So this happens before the Application object is destroyed *)
if GlobalCEFWorkScheduler <> nil then
GlobalCEFWorkScheduler.StopScheduler;
DestroyGlobalCEFApp; DestroyGlobalCEFApp;
DestroyGlobalCEFWorkScheduler;
end. end.