怎样从登陆的Form传递信息给另一个form里面的webbrowser控件?急在线等待!!!

fbonn 2008-03-20 10:11:09
怎样从登陆的Form传递信息给另一个form里面的webbrowser控件?急在线等待!!!

FormLogin.pas
unit FrmLogin;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TFormLogin = class(TForm)
GroupBox1: TGroupBox;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
EditName: TEdit;
EditPass: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormLogin: TFormLogin;

implementation

{$R *.dfm}

procedure TFormLogin.Button1Click(Sender: TObject);
begin
if (EditName.Text = 'yzx') and (EditPass.Text = '123') then
begin
self.ModalResult := mrOk; //返回mrOk,说明登陆成功
end
else
begin
ShowMessage('帐号错误!');
end;
end;

end.


//******************************************
FormMain.pas


unit FrmMain;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, OleCtrls, SHDocVw, StdCtrls, ExtCtrls, ComCtrls,
ToolWin;

type
TForm1 = class(TForm)
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ImageList1: TImageList;
Panel1: TPanel;
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
StatusBar1: TStatusBar;
WebBrowser1: TWebBrowser;
IdHTTP1: TIdHTTP;
procedure WebBrowser1DownloadBegin(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ToolBar1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation


uses FrmLogin;

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
if FormLogin.ShowModal <> mrOk then //如果返回不成功
begin
Application.Terminate;//退出!
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
StatusBar1.Panels[0].Text:='正在连接:'+Edit1.text;
end;

procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
StatusBar1.Panels[0].Text:='完成'+WebBrowser1.LocationURL ;
end;

procedure TForm1.ToolButton2Click(Sender: TObject);
begin
WebBrowser1.GoBack;
end;

procedure TForm1.ToolButton3Click(Sender: TObject);
begin
WebBrowser1.Stop;
end;

procedure TForm1.ToolButton4Click(Sender: TObject);
begin
WebBrowser1.Refresh;
end;

procedure TForm1.ToolButton5Click(Sender: TObject);
begin
WebBrowser1.GoHome;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
p:integer;
s:string;
begin

end;


procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate(Edit1.Text);
s := idHTTP1.Get('http://data.alexa.com/data?cli=10&dat=snba&url=' + Edit1.Text) ;
//先得到网页代码
p:=pos('" TEXT="',s) + Length('" TEXT="');
s:=copy(s,P,30);
p:=pos('"/>',s);
Label3.Caption:=Copy(s,1,P -1);
if Edit1.Text='' then
ShowMessage('地址不能为空');
end;

procedure TForm1.ToolBar1Click(Sender: TObject);
begin

end;

end.
请高手们指点怎样把FromLogin.pas的登录信息传递直接传递给FromMain.pas里面的webbrowser控件,急!!
...全文
38 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
我也想了解,谢谢LZ.
回复
meiZiNick 2008-05-01
这个简单啊,网上搜一下就得到答案了.
回复
相关推荐
发帖
网络通信/分布式开发
创建于2007-08-02

1573

社区成员

Delphi 网络通信/分布式开发
申请成为版主
帖子事件
创建了帖子
2008-03-20 10:11
社区公告
暂无公告