给你个示范代码吧:
//**********************************************
//工程
//***********************************************
program Project;
uses
Forms,
SysUtils,
main in 'main.pas' {MainForm},
flash in 'flash.pas' {FlashForm},
login in 'login.pas' {LoginForm};
{$R *.res}
begin
flashform:=tflashform.Create(application);
flashform.Show;
flashform.Update;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
sleep(3000); //flashform显示的时间
flashform.Close ;
flashform.Free ;
Application.Run;
end.
//**********************************************
//主窗体 (想做成什么样的程序就自己添加代码吧)
***********************************************
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,login;
type
TMainForm = class(TForm)
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.FormActivate(Sender: TObject);
begin
loginform:=tloginform.Create(application);
loginform.ShowModal;
loginform.Free;
end;
end.
//*****************************************************
//flash窗口。(嘻嘻,用来显示自己的LOGO以及软件名称)
//*****************************************************
unit flash;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TFlashForm = class(TForm)
Panel1: TPanel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
FlashForm: TFlashForm;
implementation
{$R *.dfm}
end.
//***************************************************
//登陆窗口。(验证是否为合法用户)
//***************************************************
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TLoginForm = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LoginForm: TLoginForm;
loginistrue:boolean;
implementation
{$R *.dfm}
procedure TLoginForm.BitBtn2Click(Sender: TObject);//BitBtn2:退出按钮
begin
application.Terminate;
end;
procedure TLoginForm.BitBtn1Click(Sender: TObject);//BitBtn1:登陆按钮
begin
loginistrue:=true;
{这里我省去了密码校验部分的过程,其实那个过程很好写的。if (密码正确) then
loginistrue:=true;括号中的部分也可以写成把用户输入的密码和从数据库中取的原始密码校验的过程,也可以写成对密码字符串加密解密的函数}
loginform.Close;
end;
procedure TLoginForm.FormCreate(Sender: TObject);
begin
loginistrue:=false;
end;
procedure TLoginForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if not loginistrue then
application.Terminate;//密码不对,关闭工程
end;
end.