(CodeLib-Manager)
Registriert seit: 10. Jun 2002
4.648 Beiträge
Delphi XE Professional
|
Re: TWbbrowser Formular ausfüllen und abschicken für Dummies
3. Apr 2008, 20:25
Hier noch eine Variante, ohne die 2 For-Schleifen:
Delphi-Quellcode:
uses
MSHTML;
procedure WB_FillPwdForm(WB: TWebbrowser; UsernameField, User, PasswortField, Password: string);
var
IDoc3: IHTMLDocument3;
Inputs: IHTMLElementCollection;
UID, UPWD: IHTMLElement;
begin
if Assigned(WB.Document) and
(Succeeded(WB.Document.QueryInterface(IHTMLDocument3, IDoc3))) then
begin
Inputs := IDoc3.getElementsByName(UsernameField);
if Assigned(Inputs) then
begin
UID := Inputs.item(0, '') as IHTMLElement;
if Assigned(UID) then
(UID as IHTMLInputElement).value := User;
end;
Inputs := IDoc3.getElementsByName(PasswortField);
if Assigned(Inputs) then
begin
UPWD := Inputs.item(0, '') as IHTMLElement;
if Assigned(UPWD) then
(UPWD as IHTMLInputElement).value := Password;
end;
end;
end;
// Beispiel Aufruf:
procedure TForm1.Button1Click(Sender: TObject);
begin
WB_FillPwdForm(Webbrowser1, 'login[u]','mein_Benutzername','login[p]','mein_Passwort')
end;
Thomas
|
|
Zitat
|