function  MyThread(p:Pointer):Longint;stdcall;
begin
 ADOQuery1.open;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
 HD:=CreateThread(nil,0,@MyThread,nil,0,THID)
end;我想把ADOQuery1的查询功能写到线程中去,但不知道怎么样才能把ADOQuery1传到MyThread中去(提示:Undeclared identifier:'ADOQuery1'),应该如何实现?应该是在CreateThread中的第4个参数是进行传递的
在线等谢谢。。

解决方案 »

  1.   

    typeTInsertDataThread = class(TThread)Public
        Constructor  Create(Suspended:Boolean;SDate:TAdoquery);
      

  2.   

    TInsertDataThread.create(false,Adoquery1)
      

  3.   

    Constructor TInsertDataThread.Create(Suspended:Boolean;SDate:TAdoquery);
    begin
      //Aq为声明的Tadoquery
      Aq:=SDate;
    end;
      

  4.   

    线程传参数,是比较简单的,一般的实现方法是写一个线程类,该类继承于TThread,
    需要的参数可以在线程创建的时候传入!
      

  5.   

    重构线程的constructor create函数
    unit TDFind1;interface
    uses classes,sysutils,StdCtrls,ActiveX;
    type
      TB1 = class(TThread)
      private
        s: WideString;
        procedure Update1 ;
        procedure UpdateShow;
      public
        procedure execute;override;
        constructor create(IsSuspended :Boolean;ts :String);
      end;
    implementation
    uses fCallRec,dTas,dCallRec;
    var isDw: WordBool;
    { TB1 }constructor TB1.create(IsSuspended: Boolean; ts: String);
    begin
      inherited create(IsSuspended);
      s := ts;
    end;