Delphi: TWebBrowser in the background

Can I load a webpage in TWebBrowser in a background thread?

When the application loads, I want to download the page from the Internet to TWebBrowser, but I do not want to block gui-thread.

Any suggestions?

Some clarifications:
The webbrowser component lives on the form, and I want to display the page from the Internet. But I want to do the whole loading of this page in the background thread, so loading a heavy page will not block gui-thread.

I think I am able to write topics in general.

+3
source share
3 answers

TWebBrowser . . , URL-, :

WebBrowser1.Navigate(...);
while WebBrowser1.Busy do
  Application.ProcessMessages;

ProcessMessages, - . , , , OnNavigateComplete2. , , .

, TWebBrowser , , , VCL. , TWebBrowser . Indy . .

+9

( ), Rob. , . , .

, , :

while (webBrowser1.ReadyState <>  READYSTATE_COMPLETE) do
  Application.ProcessMessages;

readystate :

const READYSTATE_UNINITIALIZED = 0; // Default initialisation state.
const READYSTATE_LOADING = 1; // Object is currently loading data.
const READYSTATE_LOADED = 2; // Object has been initialised.
const READYSTATE_INTERACTIVE = 3; // User can interact with the object but loading has not yet finished.
const READYSTATE_COMPLETE = 4; // All of the object data has been loaded.

readystate : http://gaskell.org/making-the-webbrowser-control-synchronous/

delphi readystate : http://www.cryer.co.uk/brian/delphi/twebbrowser/twebbrowser_properties.htm

+3

, - , , .

, , , . Windows , . , TWebBrowser , -, .

Threading in COM STA, .

+1

Source: https://habr.com/ru/post/1704652/


All Articles