Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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 !
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 !
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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
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 ?
thanks
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
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
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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.
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 ?
Cool ! thanks for your work
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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.
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.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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.
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.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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.
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.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
I found the problem
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.
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.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Could be add any demo or suggestion show how to add or open new page in tabs like Chrome ?
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.
The child form uses a TChromium and TCEFWindowParent in normal mode. Now the child form code is much simpler and faster.