1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
   | void __fastcall TForm1::Image1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
Target = (TImage*)Sender;
Start = Point(X,Y);
Shape->SetBounds(Target->Left, Target->Top,Target->Width, Target->Height);
Shape->BringToFront(); //au cas où...
Shape->Visible = true;
IsMoving = true;
}
 
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
if(IsMoving)
    {
    Shape->Left = Shape->Left + X - Start.x;
    Shape->Top = Shape->Top + Y - Start.y;
    Start = Point(X,Y);
    }
}
 
 
void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
if(IsMoving)
    {
    IsMoving = false;
    Shape->Visible = false;
    Target->SetBounds(Shape->Left, Shape->Top, Target->Width, Target->Height);
    }
} | 
Partager