2_ 바삭바삭 프로그래밍/C# and Visual C++
C# - 드래그로 창 이동, 폼 접기 / 폼 펼치기 / 최소화
준환이형님_
2011. 8. 17. 16:46
막상 찾으면 잘 없는 자잘한 팁 ㅋ
폼 최소화
this.WindowState = FormWindowState.Minimized;
this.Visible = false;
폼 접어놓기 / 폼 펼치기
// 1 - ClientSize는 기본 form에 있는 변수라서.. 인자를 만들지 않아도 잘라 넣어보면 그냥 있음.
ClientSize = new System.Drawing.Size(877, 321);
드래그로 창 이동
// 1
private Point mCurrentPosition = new Point(0, 0);
// 2 - 이벤트추가 마우스 다운
private void Function_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
mCurrentPosition = new Point(-e.X, -e.Y);
}
// 3 - 이벤트추가 마우스 이동
private void Function_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Location = new Point(
this.Location.X + (mCurrentPosition.X + e.X),
this.Location.Y + (mCurrentPosition.Y + e.Y));
}
}