1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| uses MSHTML_TLB, ComObj;
procedure SelectBoxInput(Browser:TWebBrowser; ElementName: string; Index: integer);
var
WebDoc : IHTMLDocument2;
pDispatch : IDISPATCH;
elements : IHTMLElementCollection;
Input: IHTMLSelectElement;
begin
OleCheck(Browser.Document.QueryInterface(IID_IHTMLDocument2, WebDoc));
elements := WebDoc.Get_all;
pDispatch := elements.item(ElementName, 0);
OleCheck(pDispatch.QueryInterface(IID_IHTMLSelectElement, Input));
Input.selectedIndex := Index;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SelectBoxInput(WebBrowser1, 'valeur_Select_Name', 1);
end; |
Partager