var
i: Integer;
ov: OleVariant;
Disp: IDispatch;
Frame: IHTMLIFrameElement;
hr: HRESULT;
begin
for i := 0 to Doc2.frames.length - 1 do
begin
ov := i;
Disp := Doc2.frames.item(ov);
if Disp = nil then Continue; hr := Disp.QueryInterface(IID_IHTMLFrameElement, Frame);
if Succeeded(hr) and (Frame2 <> nil) then
begin
OutputDebugString(PChar('frame'));
end;
end;
end;Doc2是TEmbeddedWB的属性,这种方式不行,明明网页里有iframe,if Succeeded(hr) and (Frame2 <> nil) then这一句总是失败。
var
i: Integer;
FrameBase: IHTMLFrameBase;
Disp: IDispatch;
Frame: IHTMLIFrameElement;
Elements: IHTMLElementCollection;
hr: HRESULT;
ov: OleVariant;
begin
Disp := Doc2.all.tags('iframe');
if Disp = nil then Exit;
hr := Disp.QueryInterface(IID_IHTMLElementCollection, Elements);
if Succeeded(hr) and (Elements <> nil) then
begin
for i := 0 to Elements.length - 1 do
begin
Disp := Elements.item(i, ov);
if Disp = nil then Continue;
hr := Disp.QueryInterface(IID_IHTMLFrameBase, FrameBase);
if Succeeded(hr) and (FrameBase<> nil) then
begin
hr := Disp.QueryInterface(IID_IHTMLIFrameElement, Frame);
if Succeeded(hr) and (Frame <> nil) then
begin
OutputDebugString(PChar('frame'));
end;
end;
end;
end;
end;这种方式也不行,能获取IHTMLFrameBase,IHTMLIFrameElement接口还是获取不到。
高手帮帮忙
解决方案 »
- rxrichedit中如何指定特定文字为超链
- 拖动窗体发送什么消息
- 在dephi中如何实现事务回滚,存储过程是否能实现事务回滚?
- 多个USB接口的摄像头,如何在自己的程序里自动选择视频源
- 一女生裸泳遭偷窥全过程[图]
- 请问有没有英语xmldocument控件的程序源码啊?
- 哪里有联通或移动的发短消息的代码? 谢谢告诉我啊!
- 用delphi6的向导做activeform,没有对窗体进行任何修改发布时已经被下载到了客户端,并且在在客户端成功注册,
- 怎样把一个程序添加到win2000的计划任务中,我记得好象有一个api可以用的???
- uppercase?
- 自定义组件开发,保存属性问题。
- 求 datasnap三层 数据库连接池
procedure TForm1.Button5Click(Sender: TObject);
var
doc: IHTMLDocument2;
iw: IHTMLWindow2;
pindex: oleVariant;
i: integer;
dispatch:IDispatch;
Hinput:IHTMLInputButtonElement;
mElem: IHTMLElement;
begin
doc := wb1.Document as IHTMLDocument2; pindex := 0;
dispatch := doc.frames.item(pindex);
Dispatch.QueryInterface(IHTMLWindow2,iw); for i:=0 to iw.document.all.Length-1 do
begin
dispatch := iw.document.all.item(i,0);
if succeeded(Dispatch.QueryInterface(IHTMLInputButtonElement,hinput)) then
begin
Dispatch.QueryInterface(IHTMLElement,mElem);
showmessage('click:' + mElem.outerHTML);
mElem.click;
end;
end;
end;