就好比安装程序什么的,定点在某一界面时,程学实际正在运行,这样就会出现一个label模样的'......',并且点数不断的从1到6再从1到6,直到执行完毕,说的够清楚了吧。
我知道用线程可以实现,现在就是手头没资料,线程具体是如何实现的呢,能不能给个函数过程什么的,直接 调用就OK了?如果还不清出的就看看安装程序,或者杀毒软件什么的,都有这个功能,应该不难,可我想找一个好一点方法,就上来问问,请各位大侠出出主意。

解决方案 »

  1.   

    对了,现在情况是执行一条sql语句,在执行时费时挺多,application.handleMessage用过了,没用。程序相当于处于假死状态中。不能实现。还有别的办法没?
      

  2.   

    那个label不就把他的CAPtion 在. .. ... ... 间来回切换嘛
      

  3.   

    执行到sql插入时程序就转到数据库里面去了,这样在单进程的情况下就不在执行别的了,我试了 试用个timer,根本就不走timer事件,我想就多线程可以实现了。
      

  4.   

    凑和看一下吧unit Unit2;interfaceuses
      Classes, Windows, Activex, StdCtrls,Gauges,SysUtils,Forms,ExtCtrls;type
      TTESTIMPL = class(TThread)
      private
        FLabel: TLabel;
        FStop: PBoolean;
        { Private declarations }
        procedure ShowLabel;
      protected
        procedure Execute; override;
      public
        constructor Create(vLabel: TLabel; vStop: PBoolean);
      end;implementation{ Important: Methods and properties of objects in visual components can only be
      used in a method called using Synchronize, for example,      Synchronize(UpdateCaption);  and UpdateCaption could look like,    procedure TTESTIMPL.UpdateCaption;
        begin
          Form1.Caption := 'Updated in a thread';
        end; }{ TTESTIMPL }constructor TTESTIMPL.Create(vLabel: TLabel; vStop: PBoolean);
    begin
      inherited create(false);
      FLabel := vLabel;
      FStop := vStop;
      FreeOnTerminate:=true;
    end;procedure TTESTIMPL.Execute;
    begin
      try
        CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
        while true do
        begin
          if FStop^ then Break;
          Synchronize(ShowLabel);
        end;
        CoUninitialize;
      except
      end;
      { Place thread code here }
    end;procedure TTESTIMPL.ShowLabel;
    var
      i: integer;
    begin
      for i:=1 to 6 do
      begin
        FLabel.Caption := IntToStr(i);
        application.ProcessMessages;
      end;
    end;end.unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Label1: TLabel;
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
        bStop: Boolean;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      TESTIMPL: TTESTIMPL;
    begin
      bStop := false;
      TESTIMPL := TTESTIMPL.Create(Label1,@bStop);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      bStop := true;
    end;end.
      

  5.   

    阿三说的没错,用线程!
    1.用独立的ADOCONNECTION
    2.在线程中执行TSQL
    3.定义线程的onterminate事件,当线程结束时会自动切到主线程,去显示一些结束信息或关闭gif图片!