unit WebFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls;
type
TWebForm =
class(TForm)
ActionPanel: TPanel;
WebBrowser: TWebBrowser;
LoginButton: TButton;
procedure WebBrowserBeforeNavigate2(Sender: TObject;
const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant;
var Cancel: WordBool);
procedure WebBrowserDocumentComplete(Sender: TObject;
const pDisp: IDispatch;
var URL: OleVariant);
procedure LoginButtonClick(Sender: TObject);
private
DocumentLoaded: Boolean;
end;
var
WebForm: TWebForm;
implementation
{$R *.dfm}
procedure TWebForm.WebBrowserBeforeNavigate2(Sender: TObject;
const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant;
var Cancel: WordBool);
begin
if pDisp = WebBrowser.DefaultInterface
then
DocumentLoaded := false;
end;
procedure TWebForm.WebBrowserDocumentComplete(Sender: TObject;
const pDisp: IDispatch;
var URL: OleVariant);
begin
if pDisp = WebBrowser.DefaultInterface
then
DocumentLoaded := true;
end;
procedure TWebForm.LoginButtonClick(Sender: TObject);
begin
with WebBrowser
do
begin
OnDocumentComplete := WebBrowserDocumentComplete;
Navigate('
http://www.hotmail.com');
end;
repeat
Application.ProcessMessages;
until DocumentLoaded;
with WebBrowser
do
begin
OnDocumentComplete :=
nil;
OleObject.document.forms.item(0).elements.item('
login').value:='
peter@nimmerland.de';
OleObject.document.forms.item(0).elements.item('
passwd').value:='
pan';
OleObject.document.forms.item(0).submit;
end;
end;
end.