问题描述,    本地button 动态创建 Panel 并指定parent 为 form1,可以显示,程序并不死掉
   代码太多,贴出相关代码
声明
   type
    TForm1 = class(TForm)
    ........
   private
    { Private declarations }
   public
    {Public declarations }
     MytpA   :   array[1..5]   of   TPanel;     //序列
      MytpAindex:integer;                        //当前序列号,随时变化的不存在问题
    end;Button 事件
procedure TForm1.b........begin
       MytpA[MytpAindex]:=TPanel.Create(self);
      MytpA[MytpAindex].Height:=100;
      MytpA[MytpAindex].Width:=100;
      MytpA[MytpAindex].Left:=CurrentX+; //鼠标坐标X值
      MytpA[MytpAindex].Top:=CurrentY;   //鼠标坐标Y值 
      MytpA[MytpAindex].Parent:=Form1;
end;------------以上本地执行并无问题,程序有一TcpServer控件在其  
procedure TForm1.TcpServer1Accept(Sender: TObject;
  ClientSocket: TCustomIpClient);
中同样创建       MytpA[MytpAindex]:=TPanel.Create(self);
      MytpA[MytpAindex].Height:=100;
      MytpA[MytpAindex].Width:=100;
      MytpA[MytpAindex].Left:=CurrentX+; //鼠标坐标X值
       MytpA[MytpAindex].Top:=CurrentY;   //鼠标坐标Y值        //MytpA[MytpAindex].Parent:=Form1; 不加这句 程序 并不死掉 如果加了 程序死掉期待高手,高分相送 谢谢
    

解决方案 »

  1.   

    你把新创建的Panel.name 给个名字,试试看
      

  2.   

    一样的, 问题应该不再那里 想不明白哪里错了, 实际这是一个网络五子棋 基本都完工了 ,如果我用Panel 做棋子就会出现这个问题如果我用 Label 做为棋子,就没问题,但是我又不会把Label做为圆形显示,我正在尝试用 image期待高手解决我的问题,困扰两天了 实在想不出哪里出错
      

  3.   

    注意设置新建的Panel的Parent属性,和Visible属性。相应的Button也一样。
      

  4.   

    可能我问题没描述清晰首先我在本地重复动态创建多个Panel 是没问题的Parent 设为我的窗体,Visible 设为true;---但是当我在
    TcpServer控件其  
    procedure TForm1.TcpServer1Accept(Sender: TObject; 
      ClientSocket: TCustomIpClient); 中 调用相同的方法创建 就会出问题,现象是 Panel 创建了,但是 窗口不能拖动 然后程序死掉。经过调试 发现 
        MytpA[MytpAindex].Parent:=Form1;  是这句引起,如果去掉 的话程序运行正常 但是却无法显示动态的控件了
      

  5.   

    如果是这样我还是建议你用TShape来作你重新继承一个TShape,可以加上Caption的
      

  6.   

    我只提一点,不要在线程当中操作特别是创建需要视图的VCL控件
      

  7.   

    嗯 现在已经解决了 用了 烈焰.... 说 Tshape 控件,多谢各位~