반응형
private Point mousePoint; //현재 마우스 좌표를 저장할 전역변수 선언
//코드는 예시로 디자인에서 FormBorderStyle을 None으로 설정한다.
FormBorderStyle = FormBorderStyle.None;
//LableTitle이라는 레이블 컨트롤 생성 후 마우스 다운 이벤트와 무브 이벤트 생성
private void LableTitle_MouseDown(object sender, MouseEventArgs e)
{
mousePoint = new Point(e.X, e.Y); //현재 마우스 좌표 저장
}
private void LableTitle_MouseMove(object sender, MouseEventArgs e)
{
if ((e.Button & MouseButtons.Left) == MouseButtons.Left) //마우스 왼쪽 클릭 시에만 실행
{
//폼의 위치를 드래그중인 마우스의 좌표로 이동
Location = new Point(Left - (mousePoint.X - e.X), Top - (mousePoint.Y - e.Y));
}
}
반응형
'개발언어 > C#' 카테고리의 다른 글
c# 쓰레드로 폼제어 (0) | 2019.07.10 |
---|---|
c# 이미지 전송을 위한 byte[]로 변환 메서드 (0) | 2019.07.10 |
c# Form에서 ALT+F4 막기 (0) | 2019.07.10 |
c# 폴더(디렉토리) 생성 후 삭제하기 (0) | 2019.06.28 |
c# 웹 서버에 POST 데이터 전송 메서드 (0) | 2019.06.28 |