unit Unit1;
interface
uses System, System.Drawing, System.Windows.Forms;
type
Form1 = class(Form)
procedure Move_MouseDown(sender: Object; e: MouseEventArgs);
procedure Move_MouseMove(sender: Object; e: MouseEventArgs);
{$region FormDesigner}
private
{$resource Unit1.Form1.resources}
{$include Unit1.Form1.inc}
{$endregion FormDesigner}
public
Loc: Point;
constructor;
begin
InitializeComponent;
end;
end;
implementation
procedure Form1.Move_MouseDown(sender: Object; e: MouseEventArgs);
begin
if e.Button = System.Windows.Forms.MouseButtons.Left then
Loc := e.Location;
end;
procedure Form1.Move_MouseMove(sender: Object; e: MouseEventArgs);
begin
var btn := sender as Button;
if e.Button = System.Windows.Forms.MouseButtons.Left then
begin
btn.Left += e.X - Loc.X;
btn.Top += e.Y - Loc.Y;
end;
end;
end.