1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-01-03 10:15:38 +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
* SimpleBrowser2.app/Contents/Frameworks/ExternalPumpBrowser Helper.app/
* ExternalPumpBrowser.app/Contents/Frameworks/ExternalPumpBrowser Helper.app/
* files from the demos/Lazarus_Mac/AppHelper project
* 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
*
*)
program SimpleBrowser2;
program ExternalPumpBrowser;
{$mode objfpc}{$H+}

View File

@ -42,14 +42,19 @@ unit InitSubProcess;
interface
uses
GlobalCefApplication, uCEFApplication;
GlobalCefApplication, uCEFApplication, uCEFWorkScheduler;
implementation
initialization
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
end;
end.

View File

@ -42,10 +42,10 @@ unit uExternalPumpBrowser;
interface
uses
GlobalCefApplication,
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, LMessages,
uCEFChromium, uCEFWindowParent, uCEFConstants, uCEFTypes, uCEFInterfaces,
uCEFChromiumEvents, uCEFLinkedWindowParent, uCEFWorkScheduler;
GlobalCefApplication, Classes, SysUtils, Messages, Forms, Controls, Graphics,
Dialogs, ExtCtrls, StdCtrls, LMessages, uCEFChromium, uCEFWindowParent,
uCEFConstants, uCEFTypes, uCEFInterfaces, uCEFChromiumEvents,
uCEFLinkedWindowParent, uCEFWorkScheduler;
type
@ -76,7 +76,7 @@ type
procedure GoBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
protected
// Variables to control when can we destroy the form safely
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
@ -86,6 +86,8 @@ type
procedure WMMove(var Message: TLMMove); message LM_MOVE;
procedure WMSize(var Message: TLMSize); message LM_SIZE;
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);
@ -273,6 +275,20 @@ begin
Chromium1.NotifyMoveOrResizeStarted;
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
if GlobalCEFApp = nil then begin
CreateGlobalCEFApp;
@ -284,7 +300,10 @@ initialization
finalization
(* 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;
DestroyGlobalCEFWorkScheduler;
end.