best practice to add CEF4Delphi in a legacy application
Posted: Wed Nov 17, 2021 4:41 pm
Hi.
As anticipated in https://www.briskbard.com/forum/viewtopic.php?p=7583#p7583 I ask a question on the best practices by providing an example.
You can download from https://nextcloud.nordest.systems/s/4j98T8C859xRyF6/download a zip file that contains two projects.
There are 4 folders, 2 of them contain 2 projects:

Please start with Demo Without DCEF: this is a minimalistic dummy project that represents a more complex application. The idea behind this project is to show a working application "before DCEF". The app starts by displaying a login form, then the main form with a browser tab that does not work (in the real case it was done with TWebBrowser but it makes no sense to do it in this sample so I did not add TWebBrowser).
Then a OpenCustomer button opens another form (that represents all the possible forms).
Please note that in this app all forms extend frroot.pas, so that this dummy app represents better my real world app.
Then check the Demo With DCEF: it is the same project as above but with DCEF added, in practice there are 2 places where a browser is added:
1) in the browser tab of the main form (it is possible to browse three hardcoded websites)
2) in the runtime attached page in the customer form (the browser displays a random URL)
Please be so kind to review my samples and reply to the following questions:
1) do you see any major problem in the DCEF implementation I did? Can you suggest a better approach, if any, for this type of application?
2) in the customer form with the current implementation I am not able to see the webpage (that is displayed on a runtime generated TabControlPage) unless I click on the runtime generated page, then I click on another page and finally again on the runtime generated page. I would expect to see the webpage the first time I click on the runtime generated page. Please check the code to see what's going on.
3) As I run the application I see in task manager two instances of SimpleBrowser_sp.exe (subprocess) , when in main form i go on the browser tab I see 4 instances and as I click on the 3 buttons that load other URLs I can have up to six instances but then again the number goes to four. If I open the customer form and go on the runtime generated page the number of instances is five and it returns to four as I close the form. Is this correct? I was expecting one instance per TChromiumWindow.
Please note I am using version 93 of Chromium, please have a look also at the uCEFLoader.pas unit where I assign the Browser subprocess path.
Thanks for reading, I understand there are a lot of questions, but I want to be sure what I am doing is right because I do not want to deliver to my end users something I am not 100% aware.
Bye!
As anticipated in https://www.briskbard.com/forum/viewtopic.php?p=7583#p7583 I ask a question on the best practices by providing an example.
You can download from https://nextcloud.nordest.systems/s/4j98T8C859xRyF6/download a zip file that contains two projects.
There are 4 folders, 2 of them contain 2 projects:

Please start with Demo Without DCEF: this is a minimalistic dummy project that represents a more complex application. The idea behind this project is to show a working application "before DCEF". The app starts by displaying a login form, then the main form with a browser tab that does not work (in the real case it was done with TWebBrowser but it makes no sense to do it in this sample so I did not add TWebBrowser).
Then a OpenCustomer button opens another form (that represents all the possible forms).
Please note that in this app all forms extend frroot.pas, so that this dummy app represents better my real world app.
Then check the Demo With DCEF: it is the same project as above but with DCEF added, in practice there are 2 places where a browser is added:
1) in the browser tab of the main form (it is possible to browse three hardcoded websites)
2) in the runtime attached page in the customer form (the browser displays a random URL)
Please be so kind to review my samples and reply to the following questions:
1) do you see any major problem in the DCEF implementation I did? Can you suggest a better approach, if any, for this type of application?
2) in the customer form with the current implementation I am not able to see the webpage (that is displayed on a runtime generated TabControlPage) unless I click on the runtime generated page, then I click on another page and finally again on the runtime generated page. I would expect to see the webpage the first time I click on the runtime generated page. Please check the code to see what's going on.
3) As I run the application I see in task manager two instances of SimpleBrowser_sp.exe (subprocess) , when in main form i go on the browser tab I see 4 instances and as I click on the 3 buttons that load other URLs I can have up to six instances but then again the number goes to four. If I open the customer form and go on the runtime generated page the number of instances is five and it returns to four as I close the form. Is this correct? I was expecting one instance per TChromiumWindow.
Please note I am using version 93 of Chromium, please have a look also at the uCEFLoader.pas unit where I assign the Browser subprocess path.
Thanks for reading, I understand there are a lot of questions, but I want to be sure what I am doing is right because I do not want to deliver to my end users something I am not 100% aware.
Bye!