TAdvWebBrowser OnInitialized no longer working on latest version of component

The following code no longer works and will not navigate to the url. On some of our older machine i have had to put a 3 second timer to get it to navigate after creation for it to work when before it worked fine using the oninitialized. This is using delphi 10.3

unit Unit1;

interface

uses

  • Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,*
  • Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvCustomControl, AdvWebBrowser, AdvWebBrowser.win;*

type

  • TForm1 = class(TForm)*
  • procedure FormCreate(Sender: TObject);*
  • procedure FormDestroy(Sender: TObject);*
  • private*
  • { Private declarations }*
  • DigiWebBrowserEdge: TAdvWebBrowser;*
  • procedure DigiWebBrowser1ContextPopup(Sender: TObject; MousePos: TPoint;var Handled: Boolean);*
  • procedure OnInit(Sender: TObject);*
  • public*
  • { Public declarations }*
  • end;*

var

  • Form1: TForm1;*

implementation

*{$R .dfm}

procedure TForm1.DigiWebBrowser1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
begin

  • Handled := True;*
    end;

procedure TForm1.FormCreate(Sender: TObject);
begin

  • DigiWebBrowserEdge := TAdvWebBrowser.Create(Self);*

  • TWinControl(DigiWebBrowserEdge).Parent := Self;*

  • DigiWebBrowserEdge.align := alClient;*

  • DigiWebBrowserEdge.AlignWithMargins := False;*

  • DigiWebBrowserEdge.HandleNeeded;*

  • DigiWebBrowserEdge.OnContextPopup := DigiWebBrowser1ContextPopup;*

  • DigiWebBrowserEdge.OnInitialized := OnInit;*

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin

  • FreeAndNil(DigiWebBrowserEdge);*
    end;

procedure TForm1.OnInit(Sender: TObject);
begin

end.

Thanks for any help
Lee

Set the OnInitialized event before setting the parent. You also should not call HandleNeeded

I have tried as you suggested and it is still not working. component version 1.3.3.1

procedure TForm1.FormCreate(Sender: TObject);
begin

  • DigiWebBrowserEdge := TAdvWebBrowser.Create(Self);*

  • DigiWebBrowserEdge.OnContextPopup := DigiWebBrowser1ContextPopup;*

  • DigiWebBrowserEdge.OnInitialized := OnInit;*

  • TWinControl(DigiWebBrowserEdge).Parent := Self;*

  • DigiWebBrowserEdge.align := alClient;*

  • DigiWebBrowserEdge.AlignWithMargins := False;*
    end;

Please attach the sample so we ca investigate this here

Hi attached project and exe

AdvWebbrowser Issue.zip (2.5 MB)

Thanks for the sample, we fixed the issue here, next version will address this.

Awesome Thankyoiu glad i could be of help

I have the same problem problem in version loaded few days ago 22.8.2024... I have to wait at least two seconds to navigate. Does the bug still exists?

The actual version uses OnInitialized and it is triggered as soon as the browser is properly initialized. It needs to create a cache when created programmatically so if that is what you are experiencing then yes. If you are experiencing something else, please provide a sample which is able to reproduce the issue you are describing.

I had a static TForm with a browser inside. Formerly I used OnShow to .navigate. That works all the last years. You was heading me to the right way to use OnInitzialze. This seemed to be working now. Thank you!!!