用表单传来的TComponent 而且创建的时候要用一个过程,然后用synchronize过程执行,否则将产生异常. 

解决方案 »

  1.   

    procedure thread.vclcreate;
    var button:tbutton;
    begin
      button:=tbutton.create(form1);
      button.parent:=form1;
      button.left:=10;
      button.top:=10;
    end;
    procedure thread.Execute;
    begin
      synchronize(vclcreate);
    end;
      

  2.   

    多谢xzisgood,刚从“大富翁论坛”中得知,在create事件中可以用nil作参数。如
      query1:=Tquery.create(nil);
    而且不用其它表单传来的TComponent,也不用synchronize.但本人不知其所以然?
    还请高手解释为什么可用nil作参数?
      

  3.   

    Create(aOwner...),这个VCL的owner是它所属的容器。Owner被Destroy的时候它将跟着被Destroy,为nil的话,如果不主动释放,将不会释放调直到Application终止