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.
Hi,
I have a problem that I need your help,is about How to click a button in a delphi VCL form and open it in a pop-up window, similar to clicking a hyperlink with newtarget like
If the button is used to submit some data in a <FORM> html element using the POST method then you'll have to simulate a mouse click over the button. Try sending WM_LBUTTONDOWN and WM_LBUTTONUP to TChromium.RenderHandle. If that fails you can use a browser in OSR mode and then call TChromium.SendMouseClickEvent.
https://github.com/salvadordf/CEF4Delphi/blob/82f6d8eeb6a6cf5fa09822c4b651322504e470a6/demos/Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas#L950
https://github.com/salvadordf/CEF4Delphi/blob/82f6d8eeb6a6cf5fa09822c4b651322504e470a6/demos/Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas#L884
For other situations you can use the code in the ToolBoxBrowser demo.
In ToolBoxBrowser demo, how do I click the open button and open the link using the default form instead of ChildForm? Just like clicking on the a tab in html, a new form opens and displays it.
Use the TChromiumCore.OnBeforePopup event and check the targetDisposition value like this :
https://github.com/salvadordf/CEF4Delphi/blob/82f6d8eeb6a6cf5fa09822c4b651322504e470a6/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas#L140
Setting the Result argument to True blocks all popup windows and new tabs.
The simply call TChromiuCore.LoadURL(targetUrl); to navigate using the same browser.