令
令狐小侠
Unregistered / Unconfirmed
GUEST, unregistred user!
1.由于数据量较大,所以查询的时候 想搞一个 假的进度条2.用多线程来处理,发现行不通,差资料 很多 人都这么干的,不知道我的程序问题出在那里type TThreadBar = class; TFrmProcessBar = class(TForm) BitBtn1: TBitBtn; bar: TProgressBar; procedure BitBtn1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; TThreadBar = Class(TThread) protected FrmProcessBar: TFrmProcessBar; procedure Show; procedure Barprocess; procedure Execute;override; public Constructor Create; Destructor Destroy;override; end;var ThreadBar : TThreadBar; procedure ShowBar; procedure HideBar;implementation{$R *.dfm}procedure ShowBar;begin ThreadBar := TThreadBar.Create; ThreadBar.Resume;// if (FrmProcessBar=nil) then// TFrmProcessBar;// application.CreateForm(TFrmProcessBar,FrmProcessBar);// FrmProcessBar.Show;// frmprocessbar.Invalidate;end;procedure HideBar;begin threadbar.Terminate;end;{ TThreadBar }procedure TThreadBar.Barprocess;begin FrmProcessBar.bar.Position := FrmProcessBar.bar.Position + 5; if FrmProcessBar.bar.Position>=100 then FrmProcessBar.bar.Position :=0;end;constructor TThreadBar.Create;begin inherited create(true); self.FreeOnTerminate := true; FrmProcessBar:= TFrmProcessBar.Create(nil); FrmProcessBar.Show;end;destructor TThreadBar.Destroy;begin inherited;end;procedure TThreadBar.Execute;begin while not self.Terminated do begin self.Synchronize(Barprocess); sleep(1000); end; //self.FrmProcessBar.Free;end;procedure TFrmProcessBar.BitBtn1Click(Sender: TObject);begin hideBar;end;procedure TThreadBar.Show;begin frmProcessBar.Show;end;procedure TFrmProcessBar.FormCreate(Sender: TObject);begin // ThreadBar := TThreadBar.create;end;procedure TFrmProcessBar.FormClose(Sender: TObject; var Action: TCloseAction);begin { ThreadBar.Terminate; action := cafree; FrmprocessBar := nil; }end;procedure TFrmProcessBar.FormShow(Sender: TObject);begin // ThreadBar.Resume; // self.Invalidate;end;end.