请问怎么让进度条与程序加载同步,就象有些软件在软件启动的时候用进度条程序运行的进度。。
我学delphi才几个月。。看见别人软件有这个功能,,自己也想做个,可是不会,大家可以帮帮我吗?

解决方案 »

  1.   

    搞一个Form只有进度条,挡在前面。
      

  2.   

    楼主是想在程序启动时显示进度?楼主写的软件启动时间很长?需要做很多初始化工作?
    若不是,楼主没必要这么做。一个简单的只有几个Form的程序启动时间相当快,没必要加什么进度条。若需要可以这么做:
    响应TApplication的OnIdle消息:
    procedure TForm1.ApplicationIdel(Sender:TObject)
    begin
      Application.OnIdle := nil;  ProgressBar.Position := 1;
      第1项初始化工作;  ProgressBar.Position := 2;
      第2项初始化工作;
      
      ...
    end;
      

  3.   

    progressbar看看帮助
    This example reads bytes from a file in tenths of the size of the file. The ProgressBar displays the status of each  1/10th step as it's read into the buffer.  
    The example assumes a TButton and a TProgressBar control already placed on the form.procedure TForm1.Button1Click(Sender: TObject);const
      FName = 'c:\autoexec.bat';
    var
      F: File;
      MyData: array[1..2048] of byte;
      BytesRead: LongInt;
    begin
      AssignFile(F, FName);
      try
        Reset(F);
        ProgressBar1.Max := FileSize(F);
        if (ProgressBar1.Max > 10) then
          // amount to move when StepIt method called
          ProgressBar1.Step := ProgressBar1.Max div 10
        else
          ProgressBar1.Step := ProgressBar1.Max;
        while (ProgressBar1.Position < ProgressBar1.Max) do    begin
          // read one Step size chunk of data to buffer
          BlockRead(F, MyData, ProgressBar1.Step, BytesRead);
          // move the ProgressBar Position using StepIt
          ProgressBar1.StepIt; // move by Step amount
        end;
      finally;
        CloseFile(F);
      end;
    end;
      

  4.   

    想了想,再来给楼主点建议:显示窗口创建进度:
    1. 创建一个进度显示窗体(设其类名为TProgressForm),将其改为非自动创建;
    2. 修改dpr文件:
    program ...;
    ...
    begin
      Application.Initialize;  ProgressForm := TProgressForm.Create(nil);  ProgressForm.进度条.Position := 1;
      Application.CreateForm(...);
      ProgressForm.进度条.Position := 2;
      Application.CreateForm(...);
      ...  FreeAndNil(ProgressForm);  Application.Run;
    end;
      

  5.   

    使用SplashForm类窗体,该类窗体的演示在:
    C:\Program Files\Borland\Delphi6\Demos\Db\MastApp工程中。
      

  6.   

    想了想,再来给楼主点建议:显示窗口创建进度:
    1. 创建一个进度显示窗体(设其类名为TProgressForm),将其改为非自动创建;
    2. 修改dpr文件:
    program ...;
    ...
    begin
      Application.Initialize;  ProgressForm := TProgressForm.Create(nil);  ProgressForm.进度条.Position := 1;
      Application.CreateForm(...);
      ProgressForm.进度条.Position := 2;
      Application.CreateForm(...);
      ...  FreeAndNil(ProgressForm);  Application.Run;
    end;
    ///////////////////////////////////////////////////////
     zhengji(看雨飞) 你说的这种方法我想过。。在form 个数小的地方还行的通
                     现在如果我有几百个form 的话可能。。
    我现在是想。。看有没有什么通用的方法。
      

  7.   

    自己从 TApplication 派生一类, 添加一个成员:FormCount 表示要创建的窗体的个数,
    重写 CreateForm,调用TApplication的 CreateForm ,同时给出进度显示,OK?这里所要做的只是事先算一下需要创建机个窗口而已。确定是需要改动 Delphi 既有的 Application 对象,比较麻烦,