C#

[C#]FormBorderStyle.None일 경우 화면 이동하기 예제

선영아 사랑해 2020. 1. 20. 16:25

using System.Runtime.InteropServices;


const int HT_CAPTION = 0x2;
const int WM_NCLBUTTONDOWN = 0xA1;

       

[DllImport("user32.dll")]
private static extern bool ReleaseCapture();


[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);


private void Form_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();

                SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }


마우스로 drag&drop 시 해당 FORM이 계속하여 화면에 표시하고자 할 경우 사용하시면 됩니다.

'C#' 카테고리의 다른 글

[C#]AssemblyInfo 정보 얻기 예제  (0) 2020.02.04
[C#]log4net 예제  (0) 2020.01.21
[C#]Form 위치 이동 예제  (0) 2020.01.16
[C#]신규 창 ShowInTaskbar 비활성화 예제  (0) 2020.01.07
[C#]Get Local IP Address 예제  (0) 2019.12.16