1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-07-12 22:30:17 +02:00

Fix for duplicated resources in FMX apps made by SchneiderInfosystems

- The FMX demos now load the initial web page using the TFMXChromium.DefaultUrl property.
- Added the $(FrameworkType) conditional define to all the FMX demos.
- Added the $(FrameworkType) conditional define to the CEF4Delphi_FMX project.
This commit is contained in:
Salvador Díaz Fau
2019-03-20 15:56:14 +01:00
parent 00cb710e59
commit 2ed976d906
13 changed files with 79 additions and 51 deletions

View File

@ -72,6 +72,7 @@
<SanitizedProjectName>FMXToolBoxBrowser</SanitizedProjectName>
<VerInfo_Locale>3082</VerInfo_Locale>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<DCC_Define>$(FrameworkType);$(DCC_Define)</DCC_Define>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_UsePackage>DBXSqliteDriver;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;DataSnapFireDAC;svnui;tethering;Componentes;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;Componentes_Int;IndyProtocols240;fmx;fmxdae;FireDACDBXDriver;dbexpress;vclx;dsnap;DataSnapCommon;DataSnapConnectors;VCLRESTComponents;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;DataSnapClient;bindcompdbx;vcl;DBXSybaseASEDriver;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;Componentes_UI;FireDACPgDriver;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;DbxCommonDriver;Componentes_Misc;IndySystem240;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;vclwinx;FireDACDSDriver;rtl;DbxClientDriver;IndyCore240;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;Componentes_RTF;DBXInformixDriver;bindcompvcl;Componentes_vCard;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;inetdbxpress;FireDACMongoDBDriver;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
@ -162,9 +163,10 @@
<Source Name="MainSource">FMXToolBoxBrowser.dpr</Source>
</Source>
<Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl250.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k250.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp250.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl260.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\DataExplorerDBXPluginEnt260.bpl">DBExpress Enterprise Data Explorer Integration</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k260.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp260.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">

View File

@ -19,7 +19,6 @@ object ChildForm: TChildForm
DesignerMasterStyle = 0
object FMXChromium1: TFMXChromium
OnBeforePopup = FMXChromium1BeforePopup
OnAfterCreated = FMXChromium1AfterCreated
OnBeforeClose = FMXChromium1BeforeClose
OnClose = FMXChromium1Close
Left = 40

View File

@ -59,7 +59,6 @@ type
procedure FormDestroy(Sender: TObject);
procedure FMXChromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess, Result: Boolean);
procedure FMXChromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure FMXChromium1Close(Sender: TObject; const browser: ICefBrowser; out Result: Boolean);
@ -78,7 +77,6 @@ type
public
procedure NotifyMoveOrResizeStarted;
procedure DoBrowserCreated;
procedure DoDestroyParent;
procedure SendCloseMsg;
@ -141,12 +139,6 @@ begin
FMXWindowParent.SetBounds(0, 0, ClientWidth - 1, ClientHeight - 1);
end;
procedure TChildForm.FMXChromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
// Now the browser is fully initialized we can send a message to the main form to load the initial web page.
PostCustomMessage(CEF_AFTERCREATED, 0, BrowserID);
end;
procedure TChildForm.FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
FCanClose := True;
@ -230,6 +222,7 @@ begin
TempRect.Right := round(TempClientRect.Right);
TempRect.Bottom := round(TempClientRect.Bottom);
FMXChromium1.DefaultUrl := FHomepage;
FMXChromium1.CreateBrowser(TempHandle, TempRect);
end;
end;
@ -240,12 +233,6 @@ begin
if (FMXChromium1 <> nil) then FMXChromium1.NotifyMoveOrResizeStarted;
end;
procedure TChildForm.DoBrowserCreated;
begin
// Load the homepage after the browser is fully initialized
if (length(FHomepage) > 0) then FMXChromium1.LoadURL(FHomepage);
end;
procedure TChildForm.DoDestroyParent;
begin
// We destroy FMXWindowParent safely in the main thread and this will trigger the TFMXChromium.OnBeforeClose event.

View File

@ -189,22 +189,6 @@ begin
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).DoChildDestroyed;
CEF_AFTERCREATED :
if not(Application.Terminated) then
begin
i := 0;
while (i < screen.FormCount) do
if (screen.Forms[i] is TChildForm) and
(TChildForm(screen.Forms[i]).BrowserID = TempMsg.lParam) then
begin
TChildForm(screen.Forms[i]).DoBrowserCreated;
i := screen.FormCount;
end
else
inc(i);
end;
CEF_DESTROY :
if not(Application.Terminated) then
begin

View File

@ -99,6 +99,25 @@ uses
FMX.Platform, FMX.Platform.Win,
uCEFMiscFunctions, uFMXApplicationService, uChildForm, uCEFApplication;
// This Firemonkey demo shows how to create child windows with browsers using CEF4Delphi.
// It uses a custom IFMXApplicationService to handle Windows messages.
// The application must not try to create browsers before GlobalCEFApp.GlobalContextInitialized
// is TRUE, which is set in a different thread when the GlobalCEFApp.OnContextInitialized
// event is triggered.
// There are several ways to handle the race between the form creation and the
// GlobalCEFApp.OnContextInitialized event but this demo is using a simple check
// in the TForm.OnShow event.
// All FMX applications using CEF4Delphi should add the $(FrameworkType) conditional define
// in the project options to avoid duplicated resources.
// This demo has that define in the menu option :
// Project -> Options -> Building -> Delphi compiler -> Conditional defines (All configurations)
// It's very important to close all the browsers before closing the main form.
// Always follow these destruction steps in your applications to avoid
// crashes when it's closed. Read the code comments in uChildForm.pas
// Main form destruction steps
// ===========================
// 1. Destroy all child forms