Delphi需要一个启动界面,如何制作.

linziqi0314 2007-08-13 09:51:39
急,求用delphi 2006如何制作一个软件的启动界面.
...全文
576 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cloudlyanhart 2007-08-17
  • 打赏
  • 举报
回复
学习
piaolingfeihu 2007-08-16
  • 打赏
  • 举报
回复
编程技巧 - 启动界面


程序启动欢迎窗体(Splash) 制作方法(附原码)



举个例子,你自己看吧,挺简单的

  在许多应用软件中,启动程序后,在主导界面出现之前,有一个一般以图象为主,文字为辅的画面,通常用来显示软件或公司的主题标志、软件名称、作者、版权和版本信息等,停留数秒或按了任意键后软件进入主导界面,这个画面称为Splash画面,意思为引人注目画面。这个画面的另外一个用处是在处理耗时进程时,为用户展示一幅优美、舒心的图象。

  其实在Delphi中可以很容易实现这一技巧。下面用一个例子来逐步说明如何实现Splash画面。

  1在你的程序中增加一个窗体,把它的名字改为SplashForm,BorderStyle属性设置为bsNone,Position属性设置为poScreenCenter

  2为SplashForm窗体增加一系列必要的构件,如Label、Panel、Image、Shape以及Bevel等。

  3使用IDE的Project|Option功能项把SplashForm窗体从Auto-Create表移到Available 表中。

  4将SplashForm窗体的Unit加入到主窗体Unit的Uses语句中。

  5在主程序的.dpr文件中加入一段控制代码,位置是在begin之后、其他代码之前,代码如下:

   SplashForm:=TSplashForm.create(Application);

   SplashForm.Show;

   SplashForm.refresh;

  其目的是在建立其他窗体及运行程序之前,建立并显示Splash窗体。

  6编写主窗体OnShow事件的响应过程。

   SplashForm.Free;

   在本例中,这段代码作用为当屏幕显示主窗体时,释放Splash窗体。

  7最后,为主程序的.dpr文件写一段延迟程序,目的是使Splash画面在屏幕上有一段停留的时间。最简单的办法使用一个无效循环,如:

   var i,x:longint

   for i:=1 to 100000 do

   x:=i;

  但是,由于机器运行速度不同,有快有慢,表现出来的效果并不理想,最好的办法是使用时间函数,预先规定Splash画面的停留时间。下列代码使Splash画面在屏幕上停留5 秒钟。

   var time1:TDateTime;

   time1:=now;

   repeat

   until time1+StrtoTime(′00:00:5′)<=now;

  当然,时间延迟代码必须在Splash画面显示之后,具体位置是在SplashForm.refresh; 语句的后面,建立程序主窗体之前。

  读者可以运用上述方法,在你的应用程序当中增加一个Splash画面,使你的程序更加漂亮。

  以下为程序源代码。其中Splash窗体借用了delphi\Demos\DB\MASTAPP\Splash。

   {PROJECT1.DPR}

   program Project1;

   uses

   Forms,SysUtils,

   Unit1 in ′Unit1.pas′ {Form1},

   Splash in ′..\..\Demos\DB\MASTAPP\Splash.pas′ {SplashForm};

   {R *.RES}

   var time1:TDateTime;

   begin

   SplashForm:=TSplashForm.Create(Application);

   SplashForm.Show;

   SplashForm.Refresh;

   time1:=now;

   repeat

   until time1+StrtoTime(′00:00:5′)<=now;

   Application.Initialize;

   Application.CreateForm(TForm1, Form1);

   Application.Run;

   end.

   {UNIT1.PAS 主窗体}

   unit Unit1;

   interface

   uses

   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,

   Dialogs,splash;

   type

   TForm1 = class(TForm)

   procedure FormShow(Sender: TObject);

   private

   { Private declarations }

   public

   { Public declarations }

   end;

   var

  Form1: TForm1;

   implementation

   {R *.DFM}

   procedure TForm1.FormShow(Sender: TObject);

   begin

   SplashForm.Free;

   end;

   end.

   {SPLASH.PAS Splash窗体}

   unit Splash;

   interface

   uses

   SysUtils, Windows, Messages, Classes, Graphics, Controls,

   Forms, Dialogs, StdCtrls, ExtCtrls;

   type

   TSplashForm = class(TForm)



   Panel1: TPanel;

   Label3: TLabel;

   Bevel1: TBevel;

   Label1: TLabel;

   Image1: TImage;

   end;

   var

   SplashForm: TSplashForm;

   implementation

   {R *.DFM}

   end.
------------------------------------------------------------
gooddancer 2007-08-15
  • 打赏
  • 举报
回复
Application.Initialize;
Showfrm:=tshowfrm.Create(application);
showfrm.Show;
showfrm.Update;
sleep(3000);
showfrm.Hide;
showfrm.Free;
Application.CreateForm();

以上是工程文件的代码,在application后加上一段,
启动界面就是showfrm,
iboy1983 2007-08-15
  • 打赏
  • 举报
回复
学习学习
hudixin 2007-08-15
  • 打赏
  • 举报
回复
//也可以试试以下方法:启动闪现窗口
  program Test
  uses
  forms,
  Main in 'MAIN.PAS'{MainForm},
  Move in 'Move.PAS'{MoveForm}
  {$R *.RES}
  begin
  MoveForm:=TMoveForm.Create(Application);{Create创建闪现窗口对象}
  MoveForm.Show;
  MoveForm.Update;
  Application.CreateForm(TMainForm,MainForm);
  MoveForm.Hide;
  MoveForm.Free;{Free从内存中释放对象}
  Application.Run;
  end.
  (*如果此刻你编译和运行程序,MoveForm窗口一闪而过,你可能未来得及看清。为使MoveForm窗口显示几秒种,我们可为MainForm的OnCreate 事件创建一个处理程序,延迟MoveForm窗口的显现时间。*)
  program TMainForm.FormCreate(sender:Tobject);
  var
  currentTime:LongInt;
  begin
  currentTime:=GetTickCount div 1000;
  while ((GetTickCount div 1000)<(currentTime+3) do
  begin
  end;
  end;
brightyang 2007-08-13
  • 打赏
  • 举报
回复
//主窗体
unit Unit1;

interface

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

type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

end.



//工程
program Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
application.ShowMainForm:=false;
Application.CreateForm(TForm2, Form2);
form2.Show;
Application.Run;
end.




//启动
unit Unit2;

interface

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

type
TForm2 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation
uses unit1;
{$R *.dfm}

procedure TForm2.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=false;
form1.Show;
close;
end;

end.
linziqi0314 2007-08-13
  • 打赏
  • 举报
回复
能不能给个具体点的啊,小弟是新手.能不能给详细的资料.急用
brightyang 2007-08-13
  • 打赏
  • 举报
回复
要啥样的界面就做什么样的就行了吧~~

在工程文件中加一句创建界面窗体的语句

用个定时器到了时间就把主界面show出来就行了

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧