티스토리 뷰

○ Image 컴포넌트의  MouseDown, MouseMove 이벤트를 이용해 캡션바를 사용하지 않고도 폼을 이동할 수 있도록 구현할 수 있다.

 

Unit1.h

 

public:	// User declarations
	//================================================
	//캡션바 아닌 곳에서 마우스로 이동가능하게하는루틴 변수
	int ysy_X;
                int ysy_Y;
	//=================================================

Unit1.cpp

//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y)
{
   ysy_X = X;
   ysy_Y = Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift, int X,
          int Y)
{
   if(Shift.Contains(ssLeft))
   {
	  Left = Left - ysy_X + X;
	  Top  = Top - ysy_Y + Y;
   }
}
//--------------------------------------------------------------------------