delphi - 如何让这个闪屏显示3秒?

标签 delphi delphi-2010

我使用此处提到的方法创建了启动屏幕:http://delphi.about.com/od/formsdialogs/a/splashscreen.htm

我需要在显示主窗体之前显示启动屏幕 3 秒。

请帮忙。谢谢。

最佳答案

项目文件内部:

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  uSplashScreen in 'uSplashScreen.pas' {frmSplashScreen};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;

  frmSplashScreen := TfrmSplashScreen.Create(nil);
  try
    frmSplashScreen.Show;
    // Create your application forms here
    Application.CreateForm(TForm1, Form1);

    while not frmSplashScreen.Completed do
      Application.ProcessMessages;
    frmSplashScreen.Hide;        
  finally
    frmSplashScreen.Free;
  end;

  Application.Run;
end.

内部闪屏单元:

unit uSplashScreen;

interface

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

type
  TfrmSplashScreen = class(TForm)
    Timer1: TTimer;
    procedure FormShow(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    Completed: Boolean;
  end;

var
  frmSplashScreen: TfrmSplashScreen;

implementation

{$R *.dfm}

procedure TfrmSplashScreen.FormShow(Sender: TObject);
begin
  OnShow := nil;
  Completed := False;
  Timer1.Interval := 3000; // 3s minimum time to show splash screen
  Timer1.Enabled := True;
end;

procedure TfrmSplashScreen.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  Completed := True;
end;

end.

如果创建应用程序的所有表单需要更多时间,则初始屏幕的可见时间至少为 3 秒或更长时间。

关于delphi - 如何让这个闪屏显示3秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3378605/

相关文章:

delphi - TListView - 如何在调整大小时重新排列项目

delphi - 停止 kernell32 事件

delphi - 如何在Delphi 2010中访问 'NameThreadForDebugging'

delphi - TDataSet.Insert 和 TDataSet.Append 有什么区别?

Delphi RAD 2010 更新到最新的 Indy 版本

delphi - 如何在标签标题中打印字符串?

delphi - 使用普通 csv 文件的 TStreamReader 中的编码问题

delphi - Delphi XE2 和 Delphi XE7 中 LongMonthNames 的用法

delphi-2010 - TDataModule继承

delphi - 同一台机器上的多个 Delphi 版本