hola no se si esto te sirva pero con este codigo puedes mover un boton por todo el formulario//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int XX,YY;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
enabled=true;
xo = X; //guardar posicion inicial
yo = Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if (enabled)
{
int x,y;
xn = X;
yn = Y;
if(xo > xn) //mover a la izquierda
{
x = xo - xn;
B1->Left = B1->Left - x;
}
else //mover a la derecha
{
x = xn - xo;
B1->Left = B1->Left + x;
}
if(yo > yn) //mover arriba
{
y = yo - yn;
B1->Top = B1->Top - y;
}
else //mover abajo
{
y = yn - yo;
B1->Top = B1->Top + y;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B1MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
enabled=false;
}
//---------------------------------------------------------------------------