FormBorder.None 에 간단하게 드래그이벤트 추가 코드
usingSystem;
usingSystem.Windows.Forms;
usingSystem.Runtime.InteropServices;
namespaceDragFormSample
{
publicpartialclassDragFormSample:Form
{
[DllImport("user32.dll")]
publicstaticexternintSendMessage(IntPtrhWnd,intmsg,intwParam,intlParam);
[DllImport("user32.dll")]
publicstaticexternboolReleaseCapture();
publicreadonlyintWM_NLBUTTONDOWN= 0xA1;
publicreadonlyintHT_CAPTION= 0x2;
publicDragFormSample()
{
InitializeComponent();
this.FormBorderStyle=FormBorderStyle.None;
}
protectedoverridevoidOnMouseDown(MouseEventArgse)
{
if(e.Button==MouseButtons.Left)
{
//다른 컨트롤에 묶여있을 수 있을 수 있으므로 마우스캡쳐 해제
ReleaseCapture();
//타이틀 바의 다운 이벤트처럼 보냄
SendMessage(this.Handle,WM_NLBUTTONDOWN,HT_CAPTION, 0);
}
base.OnMouseDown(e);
}
}
}