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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
//------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
rect.Left = 0;
rect.Top = 0;
rect.Right = Form1->Width;
rect.Bottom = Form1->Height;
}
//------------------------------------------------------------------------
void __fastcall TForm1::Button1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Press1 = true;
coord1.x=X;
coord1.y=Y;
}
//------------------------------------------------------------------------
void __fastcall TForm1::Button1MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Press1 = false;
}
//------------------------------------------------------------------------
void __fastcall TForm1::Button1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if(Press1)
{
static bool unefois;
unefois = !unefois;
if(!unefois)
{
Button1->Top += Y-coord1.y;
Button1->Left += X-coord1.x;
}
coord1.x=X;
coord1.y=Y;
Form1->Canvas->FillRect(rect);
TPoint points[3];
points[0] = Point(Button1->Left+Button1->Width,Button1->Top);
points[1] = Point((Button2->Left+(Button1->Left+Button1->Width))/2,Button1->Top/2);
points[2] = Point(Button2->Left,Button2->Top);
Form1->Canvas->Pen->Width = 3;
Form1->Canvas->MoveTo(Button2->Left,Button2->Top);
Form1->Canvas->PolyBezier(points,3);
}
}
//------------------------------------------------------------------------
void __fastcall TForm1::Button2MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Press2 = true;
coord2.x=X;
coord2.y=Y;
}
//------------------------------------------------------------------------
void __fastcall TForm1::Button2MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Press2 = false;
}
//------------------------------------------------------------------------
void __fastcall TForm1::Button2MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
static bool unefois;
if(Press2)
{
unefois = !unefois;
if(!unefois)
{
Button2->Top -= coord2.y-Y;
Button2->Left -= coord2.x-X;
}
coord2.y=Y;
coord2.x=X;
TPoint points[3];
points[0] = Point(Button1->Left+Button1->Width,Button1->Top);
points[1] = Point((Button2->Left+(Button1->Left+Button1->Width))/2,Button1->Top/2);
points[2] = Point(Button2->Left,Button2->Top);
Form1->Canvas->Pen->Width = 3;
Form1->Canvas->FillRect(rect);
Form1->Canvas->MoveTo(Button2->Left,Button2->Top);
Form1->Canvas->PolyBezier(points,3);
}
}
//------------------------------------------------------------------------ |
Partager