using MSHTL document without AxWebBrowser

  • Thread starter Thread starter Thomas Seidel
  • Start date Start date
T

Thomas Seidel

Hi NG,

I would like to write a specific library that gets it data from a specific
webpage.
Because not all web sites are XHTML I guess I have to use the old com
library
MSHTML. Beacause it should be all done in the library without forms I cant
use
the AxWebBrowser ocx. Thats why I tried the following:
((IHTMLDocument2)hd).write("<html></html>");

((IHTMLDocument2)hd).close();

ihd2 = ((IHTMLDocument4)hd).createDocumentFromUrl(sURL, "null");

while(ihd2.readyState != "complete")

{

Thread.Sleep(0);

}

Unfortunally it seems, that the readystatechange event will never be fired.
Is that, because of

the missing ocx? I've also tried to attach the event. How would you
implement that?

Thanks

Thomas
 
Thomas,

The code you are using is going to block, so I wouldn't recommend using
it.

Additionally, I the documentation for the readyState property states:

The IHTMLDocument2::readyState property enables the status of an object to
be tested. The correct place to test the IHTMLDocument2::readyState property
is in the event handler for onreadystatechange.

I would recommend attaching to the onreadystatechange event and then
continuing your work once it is loaded.

Hope this helps.
 
Good try. I use a console application, but added for testings
the reference to forms and that code.
Bud nothing happens. No event will be thrown. Look at my class file
in the other answer.
anyway, thanks

thomas
 
Back
Top