728x90
728x170

FomBorderStyle 이  None 인 경우 폼은 마우스로 움직일수가 없다.

그래서 찾아보니 아래처럼 하면 폼을 마우스로 움직일 수가 있다.

만약 Form 위에 Panel 이 올려져 있다면 Panel 에 이벤트를 주면된다.

using System.Runtime.InteropServices;

..... 

public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();

......
private void Form_MouseDown(object sender, MouseEventArgs e)
{
    ReleaseCapture();
    SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}

 

728x90
그리드형
Posted by kjun
,