var s:Tbutton
begin
  s:=Tbutton.create(self);
  s.parent:=self;
end;

解决方案 »

  1.   

    动态增加只要动态创建就可以了
    移动需要在鼠标左键按下以后(可以设一个布尔变量,在MouseDown时赋真,MouseUp时赋假),在OnMouseMove事件里面判断鼠标的位置,然后修改按钮位置
      

  2.   


    var s:Tbutton
    begin
    s:=Tbutton.create(self);
    s.parent:=self;
    s.OnMouseDown:=MyOnMouseDown;
    end; procedure TForm1.MyOnMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    const
      SC_DragMove = $F012;
    begin
      ReleaseCapture;
      s.perform(WM_SysCommand, SC_DragMove, 0);
    end;
      

  3.   

    procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    begin
       if (sender is Tform1 ) and (source is Tbutton ) then
          accept:=true;
    end;procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
    begin
      with source as tbutton do begin
         left:=x;
         top:=y;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
     var s:Tbutton;
    begin
      s:=tbutton.Create(self);
      s.parent:=self;
      s.DragMode :=dmAutomatic;
      s.show;
    end;
      

  4.   

    谢谢lucky和fontain()
    lucky的方法可行,不过看了fontain的方法也不会有多大问题。
    谢过二位。
      

  5.   


    只需要人民币20元,你就可以获得本灌水机的程序和Visual C++源代码,并获得永久性技术支持。还等什么?灌水等着你!就在今夜!元宵佳节!