1.生成控件
var
Button:array[1..20] of TButton;
begin
For I:=1 to 20 do
begin
Button:=TButton.Create(Self);
with Button do
begin
Name:='Button'+IntToStr(I);
Panent:=Self;
Caption:=Name;
Left:=...;
Top:=...;
OnMouseDown:=MyMouseDown;
end;
end;
end;
2.随意拖动各个BUTTON的位置
procedure MyMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbRight then
begin
ReleaseCapture;
(Sender AS TButton).Perform(WM_SysCommand, $f017, 0);
end;
end;