Hallo,
ich habe hier mal zwei "Code-Schnipsel". Das erste füllt ein Edit Feld und gibt true zurück, wenn es vorhanden ist. Das zweite betätigt einen Button.
Diese Lösung kommt auch mit mehreren Frames zurecht. Die Ursprungsversion stammt, glaub ich jedenfalls

, aus dem Swiss Delphi Center.
ciao
Matthias
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
| function FillForm(WebBrowser: TWebBrowser; FieldName: string; Value: string): Boolean; var i, j: Integer; FormItem: Variant; begin Result := False; //no form on document if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then begin Exit; end; //count forms on document for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do begin FormItem := WebBrowser.OleObject.Document.forms.Item(I); for j := 0 to FormItem.Length - 1 do begin try //when the fieldname is found, try to fill out if FormItem.Item(j).Name = FieldName then begin FormItem.Item(j).Value := Value; Result := True; end; except Exit; end; end; end; end;
function BtnClick(WebBrowser: TWebBrowser; FieldName: string): Boolean; var i, j: Integer; FormItem: Variant; begin Result := False; //no form on document if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then begin Exit; end; //count forms on document for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do begin FormItem := WebBrowser.OleObject.Document.forms.Item(I); for j := 0 to FormItem.Length - 1 do begin try //when the fieldname is found, click button if FormItem.Item(j).Name = FieldName then begin FormItem.Item(j).Click; Result := True; end; except Exit; end; end; end; end; |