Is there a way to disable the popups showing. We would like to lock the software down so our clients do not develop there own websites that cause a popup window to show over our software. I noticed in code TAdvWebBrowserPopup.Create is there away to stop this making a new windows with a property on the main browser or get it to navigate in the main browser instead of showing the popup?
Hi,
The TAdvWebBrowserPopup class is to show the browser inside a popup window. This is not related to blocking popup windows from clicking on an URL or link inside the browser itself. We have investigated this hower and the add_NewWindowRequest interface implementation is capable of doing that. The next version of TAdvWebBrowser will have this interface on board. You can use the following code to block all new windows.
uses
AdvWebBrowser.Win;
type
TCoreWebView2NewWindowRequestedEventHandler = class(TInterfacedObject, ICoreWebView2NewWindowRequestedEventHandler)
public
function Invoke(sender: ICoreWebView2; args: ICoreWebView2NewWindowRequestedEventArgs): HRESULT; stdcall;
end;
procedure TForm90.FormCreate(Sender: TObject);
var
c: ICoreWebview2Controller;
w: ICoreWebView2;
t: EventRegistrationToken;
begin
c := ICoreWebView2Controller(AdvWebBrowser1.NativeBrowser);
if c.get_CoreWebView2(w) = S_OK then
begin
w.add_NewWindowRequested(TCoreWebView2NewWindowRequestedEventHandler.Create, @t)
end;
AdvWebBrowser1.Navigate('http://tmssoftware.com');
AdvWebBrowser1.ControlAlignment := caClient;
end;
{ TCoreWebView2NewWindowRequestedEventHandler }
function TCoreWebView2NewWindowRequestedEventHandler.Invoke(
sender: ICoreWebView2;
args: ICoreWebView2NewWindowRequestedEventArgs): HRESULT;
begin
args.put_Handled(False);
Result := S_OK;
end;
[/CODE]
ICoreWebView2NewWindowRequestedEventHandler, ICoreWebView2NewWindowRequestedEventArgs, add_NewWindowRequested
undeclared
current use clause
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvCustomControl, AdvWebBrowser,
Vcl.StdCtrls, Button710, Label710, Vcl.ExtCtrls, AdvWebBrowser.Win;
Yes, Like I mentioned in the previous post: The next version of TAdvWebBrowser will have this interface on board
Sorry apologies i see what you mean now, will look forward to this then, and will add code in anticipation ready to comment back in. Thankyou
No worries, next version will have this included! :)