폼(Form) 내부를 클릭하여 이동시키는 방법

Category:
Author: zemna
Date: April 17, 2021
Share this:

WINAPI 변수 선언

public const int WM_NCLBUTTONDOWN = 0xA1;

public const int HT_CAPTION = 0x2;

Form의 MoveDown 이벤트 핸들러 작성

private void frmController_MouseDown(object sender, MouseEventArgs e)

{

    // 왼쪽버튼이 눌렸는지 확인

    if (e.Button == MouseButtons.Left)

    {

        // 발생한 이벤트를 WM_NCLBUTTONDOWN 이벤트로 변경하여 전달하기

        this.Capture = false;

        Message message = Message.Create(Handle, WM_NCLBUTTONDOWN, (IntPtr)HT_CAPTION, IntPtr.Zero);

        WndProc(ref message);

    }

}

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's connect and create
something awesome together!
2023 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram