diff --git a/demos/Lazarus_any_OS/ExternalPumpBrowser/ExternalPumpBrowser.lpr b/demos/Lazarus_any_OS/ExternalPumpBrowser/ExternalPumpBrowser.lpr index 216feb14..f78c50ae 100644 --- a/demos/Lazarus_any_OS/ExternalPumpBrowser/ExternalPumpBrowser.lpr +++ b/demos/Lazarus_any_OS/ExternalPumpBrowser/ExternalPumpBrowser.lpr @@ -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+} diff --git a/demos/Lazarus_any_OS/ExternalPumpBrowser/initsubprocess.pas b/demos/Lazarus_any_OS/ExternalPumpBrowser/initsubprocess.pas index 61730473..dfbf962e 100644 --- a/demos/Lazarus_any_OS/ExternalPumpBrowser/initsubprocess.pas +++ b/demos/Lazarus_any_OS/ExternalPumpBrowser/initsubprocess.pas @@ -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. diff --git a/demos/Lazarus_any_OS/ExternalPumpBrowser/uExternalPumpBrowser.pas b/demos/Lazarus_any_OS/ExternalPumpBrowser/uExternalPumpBrowser.pas index e9d6fdb1..dc3febcc 100644 --- a/demos/Lazarus_any_OS/ExternalPumpBrowser/uExternalPumpBrowser.pas +++ b/demos/Lazarus_any_OS/ExternalPumpBrowser/uExternalPumpBrowser.pas @@ -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.