我现在做了一个项目,我的.dpr文件第一个是主窗体,第二个才是登陆窗体,但我想登陆成功之后再显示主窗体?我的主窗体代码如下:
unit FrmMain;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Buttons, ToolWin, ComCtrls;type
TBM_OFFICE = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
bgtxl: TMenuItem;
wjpl: TMenuItem;
yzqh: TMenuItem;
yylzh: TMenuItem;
sfz: TMenuItem;
zygl: TMenuItem;
N4: TMenuItem;
exit: TMenuItem;
N6: TMenuItem;
help: TMenuItem;
jsq: TMenuItem;
kdjl: TMenuItem;
sl: TMenuItem;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
zyglSpeed: TSpeedButton;
tslButton2: TSpeedButton;
exitButton3: TSpeedButton;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
BM_OFFICE: TBM_OFFICE;implementationuses Login, bm_hintu;{$R *.dfm}procedure TBM_OFFICE.FormActivate(Sender: TObject);
begin
if not LoginExecute(TFrmLogin) then Application.Terminate;
end;
end.
登陆窗体如下:
unit Login;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, jpeg, ExtCtrls;type
TFrmLogin = class(TForm)
Login_Panel: TPanel;
Panel2: TPanel;
Label1: TLabel;
Image1: TImage;
BtnOk: TSpeedButton;
BtnExit: TSpeedButton;
EdtUsername: TEdit;
EdtPsw: TEdit;
Label2: TLabel;
Label3: TLabel;
procedure BtnOkClick(Sender: TObject);
procedure EdtUsernameKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure EdtPswKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BtnExitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
FrmLogin: TFrmLogin;
Logined: Boolean = false;
//打开登陆窗口,并判断是否登陆成功
function LoginExecute(aFormClass:TFormClass):Boolean;
implementationuses Dm, FrmMain;{$R *.dfm}{ TFrmLogin }function LoginExecute(aFormClass: TFormClass): Boolean;
begin
with aFormClass.Create(Application) do
begin
Logined :=False;
try
ShowModal;
finally
free;
end;
result := Logined;
end;
end;
procedure TFrmLogin.BtnOkClick(Sender: TObject);
var
vLogined:variant;
sql2:String;
begin
with FrmDm.purview do
begin
Close;
sql.Clear;
sql2:='select p.*,d.d_code from purview p,dept d where p.u_name='''
+EdtUsername.Text+''''+'and p.u_psw='''
+EdtPsw.Text+''''+'and p.u_dept=d.d_code';
sql.Add(sql2);
open;
if RecordCount>0 then vLogined := true
else vLogined:= false;
//密码不正确
if vLogined=false then
begin
Application.MessageBox('用户名或密码不正确,请重新输入','提示信息',mb_iconInformation);//mb_defbutton1
exit;
end
else
begin
BM_OFFICE.StatusBar1.Panels[0].Text :='系统提示:';
BM_OFFICE.StatusBar1.Panels[1].Text :='民航学院:'+
FrmDm.purview.Fields[0].AsString+'操作员';
BM_OFFICE.StatusBar1.Panels[2].Text :='登陆时间:'+
FormatDateTime('YYYY"年" MM"月" DD"日" TT',now);
end;
Logined :=true;
Close;
end;
end;end.
怎样才能实现?
unit FrmMain;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Buttons, ToolWin, ComCtrls;type
TBM_OFFICE = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
bgtxl: TMenuItem;
wjpl: TMenuItem;
yzqh: TMenuItem;
yylzh: TMenuItem;
sfz: TMenuItem;
zygl: TMenuItem;
N4: TMenuItem;
exit: TMenuItem;
N6: TMenuItem;
help: TMenuItem;
jsq: TMenuItem;
kdjl: TMenuItem;
sl: TMenuItem;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
zyglSpeed: TSpeedButton;
tslButton2: TSpeedButton;
exitButton3: TSpeedButton;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
BM_OFFICE: TBM_OFFICE;implementationuses Login, bm_hintu;{$R *.dfm}procedure TBM_OFFICE.FormActivate(Sender: TObject);
begin
if not LoginExecute(TFrmLogin) then Application.Terminate;
end;
end.
登陆窗体如下:
unit Login;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, jpeg, ExtCtrls;type
TFrmLogin = class(TForm)
Login_Panel: TPanel;
Panel2: TPanel;
Label1: TLabel;
Image1: TImage;
BtnOk: TSpeedButton;
BtnExit: TSpeedButton;
EdtUsername: TEdit;
EdtPsw: TEdit;
Label2: TLabel;
Label3: TLabel;
procedure BtnOkClick(Sender: TObject);
procedure EdtUsernameKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure EdtPswKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BtnExitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
FrmLogin: TFrmLogin;
Logined: Boolean = false;
//打开登陆窗口,并判断是否登陆成功
function LoginExecute(aFormClass:TFormClass):Boolean;
implementationuses Dm, FrmMain;{$R *.dfm}{ TFrmLogin }function LoginExecute(aFormClass: TFormClass): Boolean;
begin
with aFormClass.Create(Application) do
begin
Logined :=False;
try
ShowModal;
finally
free;
end;
result := Logined;
end;
end;
procedure TFrmLogin.BtnOkClick(Sender: TObject);
var
vLogined:variant;
sql2:String;
begin
with FrmDm.purview do
begin
Close;
sql.Clear;
sql2:='select p.*,d.d_code from purview p,dept d where p.u_name='''
+EdtUsername.Text+''''+'and p.u_psw='''
+EdtPsw.Text+''''+'and p.u_dept=d.d_code';
sql.Add(sql2);
open;
if RecordCount>0 then vLogined := true
else vLogined:= false;
//密码不正确
if vLogined=false then
begin
Application.MessageBox('用户名或密码不正确,请重新输入','提示信息',mb_iconInformation);//mb_defbutton1
exit;
end
else
begin
BM_OFFICE.StatusBar1.Panels[0].Text :='系统提示:';
BM_OFFICE.StatusBar1.Panels[1].Text :='民航学院:'+
FrmDm.purview.Fields[0].AsString+'操作员';
BM_OFFICE.StatusBar1.Panels[2].Text :='登陆时间:'+
FormatDateTime('YYYY"年" MM"月" DD"日" TT',now);
end;
Logined :=true;
Close;
end;
end;end.
怎样才能实现?
解决方案 »
- delphi Excel 导出数据
- 怎么保存一幅只有一个数字的图片的特征值
- 我有一个字符串,想判断它是否能转换为 浮点类型?因该怎么做啊。。谢谢大家了。。
- fastreport问题,100分送给主要解答建议人
- Delphi程序,在xp下打印不出来的问题怎么解决?
- 关于TListview的简单问题
- 如何在dephi 6中注册componentone的VSFlexGrid控件?
- 安装完fastreport,没有fr_class
- 拷贝ACCESS 库
- 这么多不明白的,从没听说,第一次注意,就是ms专区的名词:Exchange server ,asp.net,ADO.NET,XML/SOAP,NET Framework,Web Forms,Web Services,Windows Forms??//牛虻
- delphi里怎样退出两循环?
- treeview如果展开到第二层
// aHandle := FindWindow(nil,'Formm');
Application.Initialize;
Application.Title := 'sdd';
Application.CreateForm(tFrmLogin, FrmLogin);
//application.ShowMainForm:=false;
Application.Run;
设置主窗体
program bmglxt;uses
Forms,
FrmMain in 'FrmMain.pas' {BM_OFFICE},
Dm in 'Dm.pas' {FrmDm: TDataModule},
Login in 'Login.pas' {FrmLogin},
Test in 'Test.pas' {Form1},
bm_hintu in 'bm_hintu.pas' {BM_HINTF};{$R *.res}
to brightyang(其实我是一个程序员)
我看不明白你的;
我的工程文件如下:
begin
Application.Initialize;
Application.CreateForm(TFrmDm, FrmDm);
Application.CreateForm(TBM_OFFICE, BM_OFFICE);
//Application.CreateForm(TFrmLogin, FrmLogin);
//Application.CreateForm(TForm1, Form1);
//Application.CreateForm(TBM_HINTF, BM_HINTF);
Application.Run;
end.
begin
Application.Initialize;
Application.CreateForm(TFrmDm, FrmDm);
Application.CreateForm(TBM_OFFICE, BM_OFFICE);
//Application.CreateForm(TFrmLogin, FrmLogin);
//Application.CreateForm(TForm1, Form1);
//Application.CreateForm(TBM_HINTF, BM_HINTF);
if not LoginExecute then // 如果没有成功登录,就退出
Exit;
Application.Run;
end.