Page 1 of 1

Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Wed Jul 05, 2017 7:00 am
by crystalxp
I have searched two demos : MiniBrowser And SimpleBrowser
MiniBrowser Always load new page in the same window when clicking url with target="_blank" ;
while SimpleBrowser load it in new windows
but both are not what I wanted

Could you give us any demo or suggestion on how to Open New Page in Tabs Like Chrome

Thank you ! :D :D :D :D :D

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Wed Jul 05, 2017 8:18 am
by salvadordf
Hi,

You have two demos called MDIBrowser and ToolBoxBrowser that allow you to have many browsers in one application.

I did my own tabs for BriskBard but you can use these open source Chrome tabs :
https://github.com/norgepaul/TChromeTabs

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Wed Jul 05, 2017 8:51 am
by crystalxp
thanks :D
but these two demos also seem to opening the new page in another form ,not in tabs. and seem to a litte complex to it,as we should add much code to do so...... and the are fired by user command, not by click url :x

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Wed Jul 05, 2017 9:10 am
by salvadordf
You only have to use the TChromium.OnBeforePopup and TChromium.OnOpenUrlFromTab to save the new URL and add a new tab or popup later.

Be careful because TChromium.OnBeforePopup is called from the IO thread and TChromium.OnOpenUrlFromTab is called from the UI thread.

VCL doesn't like to create and destroy components in other threads or processes so I would save the new URLs protecting the variables inside mutexes and then send a message to the main form to add a new tab.

In the next CEF3 branch TChromium.OnBeforePopup will be called from the UI thread too and this may (hopefully) simplify a few things, specially with popups.

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Wed Jul 05, 2017 9:15 am
by crystalxp
Cool ! thanks for your work :mrgreen:

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Sat Apr 07, 2018 6:35 pm
by salvadordf
This is an old thread and the PopupBrowser demo didn't exist at that moment.

If you need to open a custom popup window with the "window.open" JavaScript command you can use the PopupBrowser demo or the MiniBrowser demo in case you want to let CEF create the popup window automatically.

For tabs it's even more complicated that the method described in the PopupBrowser demo because you would have to create a hidden browser and reparent it to the new tab when you show it for the first time.

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Sat Apr 07, 2018 7:21 pm
by salvadordf
Read the code comments in the PopupBrowser demo.

Adding new tabs would be the same but you would have to create a hidden TChromium and TWindowParent instead of a TChildForm in the CreateNextChildMsg procedure.

Instead of showing the hidden TChildForm, you would have to create a new tab and set the parent properties from TChromium and TWindowParent to the new tab.

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Sun Apr 08, 2018 5:55 pm
by salvadordf
If you want to show a popup form but you don't need to access it from javascript then you can create the child form and its browser when the global context is initialized. You would only have to return TRUE in the onbeforepopup event and then open the URL in your child form.

However, if you need to access the popup form from javascript then you can't call "createbrowser" because CEF calls cef_browser_host_create_browser_sync internally with the parameters you provide in the onbeforepopup event.

The real problem comes when you try to destroy that child form because CEF creates child "windows" in a different thread and VCL doesn't like to create and destroy "windows" in different threads.

This is the biggest problem and the cause of the bug #107 :
https://github.com/salvadordf/CEF4Delphi/issues/107

To avoid this problem we use OSR mode in popup forms because it doesn't create anything. It just updates the bitmap with the browser contents.

I'm trying to find a solution to this problem right now. I'll let you know if I find anything.

PS : I used the "window" term found in the Windows API.

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Sun Apr 08, 2018 6:43 pm
by salvadordf
I found the problem :oops:

I was reading a non existing handle and that forced the creation of that handle in a different thread.

I'll upload a new PopupBrowser2 demo very soon.

Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?

Posted: Sun Apr 08, 2018 7:39 pm
by salvadordf
I just uploaded the PopupBrowser2 demo.

The child form uses a TChromium and TCEFWindowParent in normal mode. Now the child form code is much simpler and faster.