IHTMLWindow2是在MSHTML。pas中定义的一个接口,其中有Frames属性可以访问窗口的
帧,接口的用法在COM组件的那本书里讲的还是比较细的,你可以看看下面的用法。
procedure TForm1.WebBrowserEx1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
doc:IHTMLDocument2;
all:IHTMLElementCollection;
len,i:integer;
item:OleVariant;
HtmlInputEle : IHTMLInputElement;
HoptionBtn: IHTMLselectElement;
spDisp : IDispatch;
ss:Tstrings;
begin
if url='' then
exit;
if (Uppercase(URL) = UPPercase(ladd)) and (WebBrowserEx1.Document <> nil) then
begin
doc:=WebBrowserEx1.Document as IHTMLDocument2;
all:=doc.all;
len:=all.Length;
for i:=0 to len-1 do
begin
spDisp:=all.item(i,varEmpty);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle)) then
begin
listbox1.Items.Add(HTmlInputEle.name);
if HTMlInputEle.name = 'checkbox' then
begin
if HtmlInputEle.checked then
listBox1.Items.add(HtmlInputEle.value);
end
else
begin
if HTMlInputEle.name = 'radiobutton' then
begin
if HtmlInputEle.checked then
listbox1.items.add(HtmlInputEle.Get_value);
end
else
listBox1.Items.add(HtmlInputEle.value);
end;
end;
if SUCCEEDED(spDisp.QueryInterface(IHTMLselectElement ,HOptionBtn)) then
begin
if assigned(HoptionBtn) then listBox1.Items.add(HoptionBtn.name);
if assigned(HoptionBtn) then listBox1.items.add(HoptionBtn.Get_value);
listbox1.Items.add((HoptionBtn.options as IHTMLSelectELement).value);
end;
end;
end;
end;