在TWebBrowser访问页面中的单选按钮
上一篇 /
下一篇 2008-01-18 10:41:39
/ 个人分类:Delphi程序设计
一、包含引用单元mshtml,此单元中包含了必要的接口声明
ITPUB个人空间 G"hqAy3@(Z^ gb5j
二、示例代码如下
GIl/sE'SM;t$a0
var
oz4]&s$fO5g%b-P0
doc: IHTMLDocument2;
ITPUB个人空间;xW
y.W\,V:x |
rbs: IHTMLElementCollection;
ITPUB个人空间YP7LH d'T;d MZ
rb: IHTMLOptionButtonElement;
ITPUB个人空间zD|.N Rs9B
I: Integer;
dsEB;f{0
begin
:Dh*~ `+e[nETi m0
//取得对Document对像的引用,Document对像包含当前页面中的所有对像
}m-G9urj0zDK'B0
doc := WebBrowser1.Document as IHTMLDocument2;
R-~lR&Vv)_"Q
gH0
;wX'NYb?7vE*tc Y0
//取得指定单选按钮组的引用
ITPUB个人空间 qNaM4P
rbs := doc.all.item('sex', EmptyParam) as IHTMLElementCollection;
ITPUB个人空间Jio5?]O;f
4i)]Z1Q,w0
//循环访问单选按钮组中的每个单选按钮
ITPUB个人空间6u(r.W7Y$D,v6fJ
for I := 0 to rbs.Length - 1 do
ITPUB个人空间}(d(z*r!`-v#y~
begin
ITPUB个人空间 _6eS)H p
//注意,I是第一个参数,也就是把序号做为对像名称传递
D$I:Y-M[Y9G0
rb := rbs.item(I, EmptyParam) as IHTMLOptionButtonElement;
ITPUB个人空间@
@*hAxm
//显示被选中的值
X8x?'wWZ_
kqs0
if rb.Checked then
ITPUB个人空间G,N&`7QMt}&W$a0X
ShowMessage('Checked Value:' + VarToStr(rb.value));
ITPUB个人空间d z%\lypd'W
end;
ITPUB个人空间7Z2{Q1v#O];FK
end;
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: