//---------------------------------------------------------------------------<br>#ifndef Unit1H<br>#define Unit1H<br>//---------------------------------------------------------------------------<br>#include <Classes.hpp><br>#include <Controls.hpp><br>#include <StdCtrls.hpp><br>#include <Forms.hpp><br>//---------------------------------------------------------------------------<br>class TForm1 : public TForm<br>{<br>__published: // IDE-managed Components<br> TLabel *Label1;<br> void __fastcall Label1MouseDown(TObject *Sender, TMouseButton Button,<br> TShiftState Shift, int X, int Y);<br> void __fastcall Label1MouseMove(TObject *Sender, TShiftState Shift,<br> int X, int Y);<br> void __fastcall Label1MouseUp(TObject *Sender, TMouseButton Button,<br> TShiftState Shift, int X, int Y);<br>private:<br> bool mousedown;<br> TPoint origin; // User declarations<br>public: // User declarations<br> __fastcall TForm1(TComponent* Owner);<br>};<br>//---------------------------------------------------------------------------<br>extern PACKAGE TForm1 *Form1;<br>//---------------------------------------------------------------------------<br>#endif<br><br><br>//---------------------------------------------------------------------------<br>#include <vcl.h><br>#pragma hdrstop<br><br>#include "Unit1.h"<br>//---------------------------------------------------------------------------<br>#pragma package(smart_init)<br>#pragma resource "*.dfm"<br>TForm1 *Form1;<br>//---------------------------------------------------------------------------<br>__fastcall TForm1::TForm1(TComponent* Owner)<br> : TForm(Owner)<br>{<br> mousedown = false;<br>}<br>//---------------------------------------------------------------------------<br><br>void __fastcall TForm1::Label1MouseDown(TObject *Sender,<br> TMouseButton Button, TShiftState Shift, int X, int Y)<br>{<br> mousedown = true;<br> origin.x = X;<br> origin.y = Y;<br>}<br>//---------------------------------------------------------------------------<br><br>void __fastcall TForm1::Label1MouseMove(TObject *Sender, TShiftState Shift,<br> int X, int Y)<br>{<br> if (mousedown) {<br> Form1->Left = Form1->Left + (X-origin.x);<br> Form1->Top = Form1->Top + (Y-origin.y);<br> }<br>}<br>//---------------------------------------------------------------------------<br>void __fastcall TForm1::Label1MouseUp(TObject *Sender, TMouseButton Button,<br> TShiftState Shift, int X, int Y)<br>{<br> mousedown = false;<br>}<br>//---------------------------------------------------------------------------