I'm trying to implement CEF in our ERP System to access a PWA (progressive web application). The program is module based with .bpl's.
The first thing I've tried is to compile a single Demo project. That worked fine. Then I created a new Package and kept it simple, just showing the Form with an edit and a button. Now I started to copy the SimpleBrowser step by step. I realized that the debugging wont work so I checked the .dpr first. It looks like this:
Code: Select all
program Program;
uses ...,
uCEFApplication;
{$R *.RES}
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
{$SetPEFlags $20}
begin
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutdown := True;
GlobalCEFApp.SingleProcess := True;
{$ENDIF}
GlobalCEFApp := TCefApplication.Create;
if GlobalCEFApp.StartMainProcess then
begin
Application.Initialize;
Application.Title := 'programtitle';
Application.CreateForm(TProgramFrame, ProgramModulesFrame);
Application.Run;
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.
Code: Select all
procedure TPWAModuleForm.Logging(info : String; name : String);
begin
{$IFDEF DEBUG}
AssignFile(LogFile, 'log.txt');
Append(LogFile);
if IOResult = 0 then
begin
writeln(LogFile, '[' + DateTimeToStr(now) + ']');
writeln(LogFile, 'Procedure: ' + name);
writeln(LogFile, 'Message: ' + info);
writeln(LogFile, ' ');
CloseFile(LogFile);
end;
{$ENDIF}
end;
Code: Select all
procedure TPWAModuleForm.FormShow(Sender: TObject);
begin
ChromiumWindow1.ChromiumBrowser.OnBeforePopup := Chromium_OnBeforePopup;
Logging('Chromium_OnBeforePopup: Popups and new Tabs blocked', 'FormShow');
if not(ChromiumWindow1.CreateBrowser) then
begin
Timer1.Enabled := True;
Logging('Timer1 enabled | !ChromiumWindow1.CreateBrowser: Browser not created yet', 'FormShow');
end;
end;
I hope I could explain my problem good enough.
Thanks in advance!
Greets