C#无框窗体移动

C#无框窗体移动

无框窗体移动

//添加命名空间:using System.Runtime.InteropServices;

在 public partial class Form1 : Form
{
[DllImport(“user32.dll”)]
public static extern bool ReleaseCapture();
[DllImport(“user32.dll”)]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);}

// Form1_MouseDown事件
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
	if (e.Button == MouseButtons.Left)
	{
		ReleaseCapture(); //释放鼠标捕捉
		//发送左键点击的消息至该窗体(标题栏)
		SendMessage(Handle, 0xA1, 0x02, 0);
	}
}

}这样就很简单啦.朋友

发布了7 篇原创文章 · 获赞 0 · 访问量 69

猜你喜欢

转载自blog.csdn.net/m0_37912920/article/details/105060522
今日推荐