based on MSHTML documentation for IHTMLDocument2 I'm trying to write a simple HTML parser. Unfortunately, trying to set the editing mode does not work, in other words, resultState never gets a “full” value, so the application freezes.
{$APPTYPE CONSOLE} function ParseHtml(doc: TStringList): TStringList; var iHtml: IHTMLDocument2; v: Variant; msg: tagMSG; begin iHtml := CreateComObject(CLASS_HTMLDocument) as IHTMLDocument2; Result := TStringList.Create; try try iHtml.designMode := 'on'; while iHtml.readyState <> 'complete' do PeekMessage(msg, 0, 0, 0, PM_NOREMOVE); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // above loop never finishes v := VarArrayCreate([0, 0], varVariant); v[0] := doc.Text; iHtml.write( PSafeArray(TVarData(v).VArray) ); iHtml.designMode := 'off'; while iHtml.readyState <> 'complete' do PeekMessage(msg, 0, 0, 0, PM_NOREMOVE); // processing iHtml.body ... except ... end; finally ... end; ... end; begin CoInitialize(nil); ... CoUninitialize; end.
Just curious why the readyState property of the IHTMLDocument2 interface is never set to 'complete', although it should be based on official documentation?
David unric
source share