如何在 Turbo Delphi 上制作带有进度条的启动画面? [英] How to make a splash screen with a progress bar on Turbo Delphi?

查看:104
本文介绍了如何在 Turbo Delphi 上制作带有进度条的启动画面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(Unit1.pas)

(Unit1.pas)

    unit Unit1;

    interface

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

    type
      TForm1 = class(TForm)
        Button1: TButton;
        Label1: TLabel;
        Timer1: TTimer;
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure OpenSplash;
        procedure ShowProgress;
        procedure CloseSplash;
      end;

    var
      Form1: TForm1;
          X: Integer;
          Total: Integer;
          Percent: Integer;

    implementation

    {$R *.dfm}
     procedure TForm1.OpenSplash;
    begin
      Label1.Caption := '';
      Show;
      Update;



    end;

procedure TForm1.CloseSplash;
begin
  Form1.Destroy;
end;


procedure TForm1.ShowProgress;
begin
Label1.caption:='';
   Total := 1000;
      for X := 1 to Total do
      begin
        Sleep(5);
        Percent := (x * 100) div Total;
        Label1.caption := StringOfChar('|', Percent) + IntToStr(Percent) + '%';
        Label1.Repaint;

      end;
end;

 procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Close;
  Release;
  Form1 := nil;
end;

end.

(Unit2.pas)

(Unit2.pas)

unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    memo1: TMemo;

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}
function Splash: TForm2;
begin
  if Form2 = nil then begin
    Form2 := TForm2.Create(Application);
  end;
  result := Form2;
end;
end.

(*.dpr)

program Project1;

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

{$R *.res}

begin
  Application.Initialize;
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm1, Form1);
  Form1.CloseSplash;
  Application.Run;
end.

推荐答案

也许 this 对你来说很有趣.

Maybe this is interesting for you.

这篇关于如何在 Turbo Delphi 上制作带有进度条的启动画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆