Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MSHTML remains in ReadyState_Interactive forever (when the control window is not yet visible)

492 views
Skip to first unread message

Thomas Zangl

unread,
Feb 21, 2005, 9:19:09 AM2/21/05
to
Hi,

I came over a portion of code like this (Delphi):
(FIE is a TWebBrowser - Embedded IE Control)

FIE.Navigate(Filename);
while (FIE.ReadyState <> ReadyState_Complete) do
Application.ProcessMessages;

This does nothing else than loading a file/url into the Browser. So far
so good - it works if the MSHTML Window is visible. If the MSHTML Window
is NOT visible it remains in this state: ReadyState_Interactive
(According to MSDN this means: Object is interactive, but not all of its
data is available.) Why is MSHTML not proceeding? My app is ending in an
endless loop because of this :-/

TIA,
--
----------------------------------------------------------------
,yours Thomas Zangl -th...@tzi.dhs.org- -TZ1-6BONE-
-http://tzi.dhs.org - http://www.borg-kindberg.ac.at
Use YAMC! now! Get it at http://www.borg-kindberg.ac.at/yamc/

Charles Law

unread,
Feb 21, 2005, 9:55:57 AM2/21/05
to
Hi Thomas

I suspect that this is 'by design'. The WebBrowser control is designed for
rendering html pages. If the control is not visible then the content is not
rendered, and if it is not rendered then the data is not available.

Charles


"Thomas Zangl" <use...@tzis.net> wrote in message
news:37u8ufF...@individual.net...

Thomas Zangl

unread,
Feb 21, 2005, 10:12:58 AM2/21/05
to
Charles Law wrote:

Hi!

> I suspect that this is 'by design'. The WebBrowser control is designed for
> rendering html pages. If the control is not visible then the content is not
> rendered, and if it is not rendered then the data is not available.

That renders MSHTML to be useless to me :-/ I can live with the fact
that it is inactive but this also means that the Document Object has no
body elemtn (FDocument.body is nil) - so I can´t modify/load any HTML
into the control :-/

Any idea how to mimic the behavior of DHTML beside some dirty "OnShow"
event hacks?

--
Thomas

Charles Law

unread,
Feb 21, 2005, 11:34:31 AM2/21/05
to
Do you require the rendering features? If that is the case, and you will
never want to show the page, you don't need the full WebBrowser control.
Instead, just use mshtml. Note that the WebBrowser wraps mshtml and shdocvw.
The latter provides the rendering services whilst the former maintains the
DOM.

You can create and manipulate a page in memory using just mshtml. You will
need the IPersistStreamInit interface exposed by the document object.

Navigate to about:blank on a new HTMLDocument object and wait for complete.
Call InitNew on the IPersistStreamInit interface.
Call Load to load a string.
Wait for complete.

If you need to view the page can you not allow the control to be visible?

Charles


"Thomas Zangl" <tho...@tzis.net> wrote in message
news:urclMfCG...@tk2msftngp13.phx.gbl...

Thomas Zangl

unread,
Feb 21, 2005, 12:57:43 PM2/21/05
to
Charles Law wrote:

Hi!

> Do you require the rendering features?

More or less: yes.
Not really immediatly, but after I loaded/modified the HTML code it
should be displayed/editable.

> Navigate to about:blank on a new HTMLDocument object and wait for complete.
> Call InitNew on the IPersistStreamInit interface.
> Call Load to load a string.
> Wait for complete.

Idea:

I create an IHTMLDocument2 object - fill and modify it. How can I now
attach the object to the Webbrowser object?
Maybe someone can provide me sample code? :)

> If you need to view the page can you not allow the control to be visible?

I can - but in the same procedure I want load the HTML string into the
control.... so it might not matter if its visible or not :-/

Best regards,

geoff_syndicate

unread,
Feb 21, 2005, 4:28:41 PM2/21/05
to
Charles Law wrote:
> Hi Thomas
>
> I suspect that this is 'by design'. The WebBrowser control is designed for
> rendering html pages. If the control is not visible then the content is not
> rendered, and if it is not rendered then the data is not available.
>
> Charles
>
>

I use the WebBrowser control in this way with no problems. I use dirty
old Visual Basic, and my WebBrowser control is hidden and I wait until
it's finished loaded and then access the HTMLDocument interface. Here
is the code I use:

If ie.Offline = True Then
pageTimer.Duration = 10000
Else: pageTimer.Duration = 60000
End If

pageTimer.Enabled = True
ie.Visible = False
ie.Navigate strLocation

Do While ie.ReadyState <> READYSTATE_COMPLETE
DoEvents
If pageTimer.TimeRemaining = 0 Then
ie.Stop
Exit Do
End If
Loop

pageTimer.Enabled = False

DoEvents
Set thisIE = ie.Document
DoEvents
Set thisIEWindow = thisIE.parentWindow
DoEvents

'ie' is the webBrowser and 'thisIE' is an HTMLDocument variable.
thisIEWindow is an HTMLWindow variable.
I have included a timer to abort the load if it seems to be in an
infinite loop.

This is quite basic but works well.

Geoff

0 new messages