Hidden advwebbrowser in a form: is it possible?

Is it possible to have a non visible (hidden) advwebbrowser that we could use to surf and monitoring pages in a vcl program?
Either with advwebbrowser or TMSFNCEdgewebbrowser?
Do you propose a demo for that?

Sometimes it is more easy to have a web browser to surf in a webpage, as hidden process to our application's user and provided the functions through our vcl application's interface.
Thank you in advance

Hi,

Unfortunately no, for the webbrowser to properly initialize, it needs to be visible and have a valid handle. Once it's initialized, you can try to hide it by setting Visible := False, but it's unclear if the browser will then react to URL changes.

to be honest I put a advwebbrowser with visible=false in a form and with a tbutton using the following code:

procedure TForm1.AdvWebBrowser1DocumentComplete(Sender: TObject);
begin
showmessage('page loaded: '+AdvWebBrowser1.URL);
end;

procedure TForm1.AdvWebBrowser1Initialized(Sender: TObject);
begin AdvWebBrowser1.Navigate('https://www.tmssoftware.com'); end;

procedure TForm1.Button1Click(Sender: TObject);
begin
AdvWebBrowser1.Visible:=true;
end;

From what I checked, initialized is fired and the page is loaded, but the "DocumentComplete" is never run.
When button is pressed, the page was loaded ok and it becomes instantly visible

OnDocumentComplete is not fired until you manually call StartDocumentReadyStateThread

1 Like

Now after a couple of seconds OnDocumentComplete is also fired.
So probably, it works for some tasks.
What should we expect not to work when not visible?

It's unclear, an unvisible browser most likely will not navigate