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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.
When I click on a button on a webpage I want the page not to open in a new window (which is the default) but rather open in another view (TWVWindowParent) on the same form. Is this possible?
I know I need to use the OnNewWindowRequested() event but not sure what to place in the parameters
The PopupBrowser demo shows how to open a browser in a child form and you can use most of that code.
Follow these steps :
Use the TWVBrowser.OnNewWindowRequested event and create a TCoreWebView2NewWindowRequestedEventArgs instance with the "aArgs" parameter. Call it "MyArgs".
Create a TCoreWebView2Deferral instance with "MyArgs.Deferral" in the Create constructor. Call it "MyDeferral".
Call TWVBrowser.CreateBrowser for the new browser.
Use the TWVBrowser.OnAfterCreated event to set MyArgs.NewWindow and MyArgs.Handled. Also call MyDeferral.Complete.
private
{ Private declarations }
//* Send to another web browser on the same form
FArgs: TCoreWebView2NewWindowRequestedEventArgs;
FDeferral: TCoreWebView2Deferral;
private
{ Private declarations }
//* Send to another web browser on the same form
FArgs: TCoreWebView2NewWindowRequestedEventArgs;
FDeferral: TCoreWebView2Deferral;