我的要求是象安装程序一样,刚查询就启动进程条,进程条的速度和查询同步,等查询结束,进程条也显示结束,最好还能有个百分比显示(在BDE下)

解决方案 »

  1.   

    procedure TFRMBoxInvMst.FilePrintSetupExecute(Sender: TObject);
    var
      AForm: TForm;
      ALabel: TLabel;
      APBar: TProgressBar;  NoteNo: String;
    begin
      inherited;
      NoteNo := '';
      AForm := TForm.Create(nil);
      try
        with AForm do
        begin
          Caption := '進度條...';
          Height := 150;
          Width := 400;
          BorderIcons := [];
          Position := poScreenCenter;
        end;
        ALabel := TLabel.Create(AForm);
        APBar := TProgressBar.Create(AForm);    ALabel.Caption := '正在准備報表數據, 請稍候...';
        ALabel.Top := 20;
        ALabel.Left := 30;
        ALabel.Width := AForm.Width - 2* ALabel.Left;
        ALabel.Parent := AForm;    APBar.Top := 55;
        APBar.Left := ALabel.Left;
        APBar.Smooth := True;
        APBar.Width := ALabel.Width;
        APBar.Min := 0;
        APBar.Max := 1000;
        APBar.Step := Trunc(APBar.Max / MasterDataSet.RecordCount);
        APBar.Parent := AForm;    AForm.Show;    NoteNo := NewNoteNo('ABOXINVPD');    DM.csCommand.Active := False;
        DM.csCommand.CommandText := 'INSERT INTO BOXINVPD(CMPYCD, NOTENO, PATCODE, BILLQTY, CREATEUSERID)'
                                    + ' VALUES(:CMPYCD, :NOTENO, :PATCODE, :BILLQTY, :CUSERID)';
        DM.csCommand.Params.ParseSQL(DM.csCommand.CommandText, True);
        with MasterDataSet do
        begin
          DisableControls;
          First;
          while not eof do
          begin
            DM.csCommand.Params.ParamByName('CMPYCD').AsString := DM.csCmpy.FieldValues['CUSTOMERCD'];
            DM.csCommand.Params.ParamByName('NOTENO').AsString := NoteNo;
            DM.csCommand.Params.ParamByName('PATCODE').AsString := FieldByName('PATCODE').AsString;
            DM.csCommand.Params.ParamByName('BILLQTY').AsInteger := FieldByName('TQTY').AsInteger;
            DM.csCommand.Params.ParamByName('CUSERID').AsString := DM.SystemInfo.CurrentUser.ID;        DM.csCommand.Execute;
            Next;
            APBar.StepIt;
            APBar.Update;
            AForm.Update;
          end;
          EnableControls;
        end;
        MsgBox('盤點報表數據處理完畢!        ');
      finally
        AForm.Release;
      end;
    end;
      

  2.   

    这就需要你首先知道你要查询的数据的总条数,然后才可以做进度条。每查到一定数量的记录就将ProgressBar.StepIt
      

  3.   

    to chutian(我很丑???) 
    在未打开数据之前,如何得知masterdataset.recordcount????
    APBar.Step := Trunc(APBar.Max / MasterDataSet.RecordCount);
    还有DM.csCommand是什么??麻烦您告之,谢谢