FormBoardStyle이 None 일때 Form을 이동하기 위한 방법입니다.
Item_MouseMove 이벤트 함수를 컨트롤의 MouseMove 이벤트에 등록해서 사용하게되며 필요한 하위 컨트롤에 등록해서 함께 사용합니다.
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private void Item_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
※ 출처 : Move window/form without Titlebar in C# - CodeProject
'.Net Framework Standard > WindowsApplication' 카테고리의 다른 글
C# Winform - 마우스 포인터가 있는 모니터에 Form 열기 (0) | 2024.01.05 |
---|---|
ClickOnce - System.Security.SecurityException 오류 ( System.Threading.Thread.set_CurrentCulture) (0) | 2022.03.04 |
IIS 보안 적용시 ClickOnce 사용 - TLS (0) | 2017.08.02 |
Duplex Service 샘플 두가지 입니다. (0) | 2016.06.20 |
Visual Studio 조건부 컴파일 기호(전처리, define) 변경에 따른 참조 DLL 경로 자동 변경 입니다. (0) | 2016.06.20 |