Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在TurboDelphi上使用进度条创建初始屏幕?_Delphi_Progress Bar_Vcl_Splash Screen - Fatal编程技术网

如何在TurboDelphi上使用进度条创建初始屏幕?

如何在TurboDelphi上使用进度条创建初始屏幕?,delphi,progress-bar,vcl,splash-screen,Delphi,Progress Bar,Vcl,Splash Screen,(单元1.考绩制度) (第二单元考绩制度) (*.dpr) 在*.dpr中,尝试以下操作: begin Application.Initialize; FormSplash := TFormSplash.Create( Application ); FormSplash.OpenSplash; // Do the rest of your initialisation... // MAKE SURE THERE'S NO CreateForm FOR FormSplash!

(单元1.考绩制度)

(第二单元考绩制度)

(*.dpr)


在*.dpr中,尝试以下操作:

begin
  Application.Initialize;
  FormSplash := TFormSplash.Create( Application );
  FormSplash.OpenSplash;
  // Do the rest of your initialisation...
  // MAKE SURE THERE'S NO CreateForm FOR FormSplash!
  FormSplash.ShowProgress( "Creating a form..." );
  Application.CreateForm( ... , ... );
  ...
  // When you want to modify the splashscreen, do something like this:
  FormSplash.ShowProgress( "Doing something else..." );
  ...
  // Close the splash screen
  FormSplash.CloseSplash;
  Application.Run;
end.
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm1, Form1);
  Form1.CloseSplash;

您不需要对FormUtama类型进行任何引用。

在*.dpr中,尝试以下操作:

begin
  Application.Initialize;
  FormSplash := TFormSplash.Create( Application );
  FormSplash.OpenSplash;
  // Do the rest of your initialisation...
  // MAKE SURE THERE'S NO CreateForm FOR FormSplash!
  FormSplash.ShowProgress( "Creating a form..." );
  Application.CreateForm( ... , ... );
  ...
  // When you want to modify the splashscreen, do something like this:
  FormSplash.ShowProgress( "Doing something else..." );
  ...
  // Close the splash screen
  FormSplash.CloseSplash;
  Application.Run;
end.
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm1, Form1);
  Form1.CloseSplash;

您不需要对FormUtama类型进行任何引用。

在项目代码中,您是这样做的:

begin
  Application.Initialize;
  FormSplash := TFormSplash.Create( Application );
  FormSplash.OpenSplash;
  // Do the rest of your initialisation...
  // MAKE SURE THERE'S NO CreateForm FOR FormSplash!
  FormSplash.ShowProgress( "Creating a form..." );
  Application.CreateForm( ... , ... );
  ...
  // When you want to modify the splashscreen, do something like this:
  FormSplash.ShowProgress( "Doing something else..." );
  ...
  // Close the splash screen
  FormSplash.CloseSplash;
  Application.Run;
end.
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm1, Form1);
  Form1.CloseSplash;

实际上,在创建Form1之前,您正在使用Form1中的方法。这专门用于解决项目代码中的问题…

您正在这样做:

begin
  Application.Initialize;
  FormSplash := TFormSplash.Create( Application );
  FormSplash.OpenSplash;
  // Do the rest of your initialisation...
  // MAKE SURE THERE'S NO CreateForm FOR FormSplash!
  FormSplash.ShowProgress( "Creating a form..." );
  Application.CreateForm( ... , ... );
  ...
  // When you want to modify the splashscreen, do something like this:
  FormSplash.ShowProgress( "Doing something else..." );
  ...
  // Close the splash screen
  FormSplash.CloseSplash;
  Application.Run;
end.
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm1, Form1);
  Form1.CloseSplash;

实际上,在创建Form1之前,您正在使用Form1中的方法。这是专门用来解决问题的…

以下是结论

program Project1;

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

{$R *.res}

begin
  Application.Initialize;
  Form1 := TForm1.Create( Application );
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm2, Form2);
  Form1.CloseSplash;
  Application.Run;
end.
第一单元

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
  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;

end.
第二单元

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}

end.

非常感谢那些回答我问题的人。

以下是结论

program Project1;

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

{$R *.res}

begin
  Application.Initialize;
  Form1 := TForm1.Create( Application );
  Form1.OpenSplash;
  Form1.ShowProgress;
  Application.CreateForm(TForm2, Form2);
  Form1.CloseSplash;
  Application.Run;
end.
第一单元

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
  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;

end.
第二单元

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}

end.

非常感谢那些回答我问题的人。

也许对你来说很有趣。

也许对你来说很有趣。

在项目源代码的begin语句(即.dpr文件)之后添加此代码:

在最终的Application.Create()之后和Application.Run之前运行:

SplashScreen.Hide;
SplashScreen.Free;

在项目源代码(.dpr文件)的begin语句之后添加此代码:

在最终的Application.Create()之后和Application.Run之前运行:

SplashScreen.Hide;
SplashScreen.Free;

我像这个项目一样做了;使用表单,“Splash.pas”{FormSplash}中的Splash,以及“SplashProject.pas”{Form1}中的SplashProject;{$R*.res}开始应用程序。初始化;Application.OpenSplash;Application.CreateForm(TForm1,Form1);Splash.CloseSplash;应用程序。运行;结束。仍然发现一些错误,我只需要3个过程:1。Application.initialize 2.FormSplash.OpenSplash;FormSplash.ShowProgress(FormSplash,TFormSplash);3.Application.CreateForm(FormUtama、TFormUtama);FormSplash.CloseSplash;应用程序。运行;但我仍然有同样的问题,当你创建splashform时,FormUtamaAssigning应用程序上的“ShowProgress”作为所有者是浪费处理器周期的,如果你自己释放它的话(顺便说一句,你没有这样做,你让它在程序运行的整个生命周期中都挂在内存中)。是的,你说得对-我是盲目编码的&修改我的首选代码(类方法等)以适应Otip88的现有代码。好地方:}我已经像这个程序一样完成了项目1;使用表单,“Splash.pas”{FormSplash}中的Splash,以及“SplashProject.pas”{Form1}中的SplashProject;{$R*.res}开始应用程序。初始化;Application.OpenSplash;Application.CreateForm(TForm1,Form1);Splash.CloseSplash;应用程序。运行;结束。仍然发现一些错误,我只需要3个过程:1。Application.initialize 2.FormSplash.OpenSplash;FormSplash.ShowProgress(FormSplash,TFormSplash);3.Application.CreateForm(FormUtama、TFormUtama);FormSplash.CloseSplash;应用程序。运行;但我仍然有同样的问题,当你创建splashform时,FormUtamaAssigning应用程序上的“ShowProgress”作为所有者是浪费处理器周期的,如果你自己释放它的话(顺便说一句,你没有这样做,你让它在程序运行的整个生命周期中都挂在内存中)。是的,你说得对-我是盲目编码的&修改我的首选代码(类方法等)以适应Otip88的现有代码。好地方:}我更新了我的编码。。。仍然发现一些错误。。。请帮帮我…我更新了我的编码。。。仍然发现一些错误。。。请帮帮我。。。