W
weitu
Unregistered / Unconfirmed
GUEST, unregistred user!
可能上个问题说的不太清楚,致使无人问津,现在将代码简化,再次发表。
问题是:ShowMessage 为何总是0。下面是我的代码:
procedure TForm1.FormCreate(Sender: TObject);
var
IDoc : IHTMLDocument2;
strHTML : String;
v : Variant;
begin
IDoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
try
IDoc.designMode := 'on';
while IDoc.readyState <> 'complete' do
Application.ProcessMessages;
v:= VarArrayCreate([0,0],VarVariant);
strHTML := IdHttp.Get('http://www.sina.com.cn/');
v[0]:= strHTML;
IDoc.write(PSafeArray(System.TVarData(v).VArray)) ;
IDoc.designMode:='off';
while IDoc.readyState <> 'complete' do
Application.ProcessMessages;
ShowMessage(IntToStr(HtmlDoc.Body.getAttribute('offsetHeight', 0)));
finally
IDoc := nil;
end;
end;
问题是:ShowMessage 为何总是0。下面是我的代码:
procedure TForm1.FormCreate(Sender: TObject);
var
IDoc : IHTMLDocument2;
strHTML : String;
v : Variant;
begin
IDoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
try
IDoc.designMode := 'on';
while IDoc.readyState <> 'complete' do
Application.ProcessMessages;
v:= VarArrayCreate([0,0],VarVariant);
strHTML := IdHttp.Get('http://www.sina.com.cn/');
v[0]:= strHTML;
IDoc.write(PSafeArray(System.TVarData(v).VArray)) ;
IDoc.designMode:='off';
while IDoc.readyState <> 'complete' do
Application.ProcessMessages;
ShowMessage(IntToStr(HtmlDoc.Body.getAttribute('offsetHeight', 0)));
finally
IDoc := nil;
end;
end;