See when Delphi Twebbrowser starts loading a page

1.4k views Asked by At

I am using delphi's TWebbrowser to navigate to a php file I created. I have a loading screen I would like to show when the page is loading or processing commands.

How can I detect when it is being refreshed or still loading.

currently I am using the ondocumentcomplete to close the loading form and re-enable the main form once loading is done.

I have tried the onbeforenavigate2 to show the loading screen and disable the main form. But then after it has finished loading, and the document completes, the navigate2 process is run again. And the form again disabled.

is there any way to detect when the browser is loading a page?

1

There are 1 answers

3
SilverWarior On BEST ANSWER

The events that you are searching for are OnDownloadBegin and OnDownloadComplete.

OnDownloadBegin fires just before the document starts to being downloaded and is therefore the best event for starting of some loading animation.

http://docwiki.embarcadero.com/Libraries/XE8/en/SHDocVw.TWebBrowser.OnDownloadBegin

OnDownloadComplete fires after the document was downloaded and even if the downloading of the document fails for some reason. So it is best even for stopping of some loading animation.

http://docwiki.embarcadero.com/Libraries/XE8/en/SHDocVw.TWebBrowser.OnDownloadComplete