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);
}
}
}
'프로그래밍 > C#.net' 카테고리의 다른 글
작업표시줄에 App 숨기는 꽁수 (0) | 2009.03.24 |
---|---|
바탕화면을 부모로 가지기 (0) | 2009.03.24 |
WinService구동시 installutil문제 (2) | 2009.02.17 |
[C#] AutoResetEvent 와 ManualResetEvnet 예제 (0) | 2009.01.15 |
동기화 테스트 예제 (0) | 2009.01.15 |
댓글