新
新来的菜鸟
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在查询的时候做一个假进度条,目的是在查询的时候弹出一个加的进度条在跑,等查询的数据出来后就关闭这个进度条!我现在新建一个线程把查询放进这个线程里,当数据出来后就把进度条窗口关闭,但我运行后好像没反应,那位大哥能帮小弟看看,小弟谢谢了!unit frmMain;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uSafeThread, StdCtrls, Grids, DBGridEh, DB, ADODB, ComCtrls, ExtCtrls,ACTIVEX;type TMyThread = class(TThread) private protected procedure Execute; override; public constructor Create; virtual; end;type TForm1 = class(TForm) Button1: TButton; DBGridEh1: TDBGridEh; ADOQuery1: TADOQuery; DataSource1: TDataSource; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; HSem : THandle = 0 ;implementationuses Unit2;{$R *.dfm}var tick: Integer = 0; constructor TMyThread.Create;begin inherited Create(true); FreeOnTerminate := True;end;procedure TMyThread.Execute;var go:boolean ;begin go:=true; repeat coInitialize(nil); Form1.ADOQuery1.Close; Form1.ADOQuery1.SQL.Clear; Form1.ADOQuery1.SQL.Add('exec p_mzd_yb'); Form1.ADOQuery1.Open; Form2.close; until go=false;end;procedure TForm1.FormCreate(Sender: TObject);beginHSem:=CreateSemaphore(Nil,1,1,Nil) ;end;procedure TForm1.FormDestroy(Sender: TObject);beginCloseHandle(HSem) ;end;procedure TForm1.Button1Click(Sender: TObject);begin form2.Show; TMyThread.Create;end;end.