C#怎么实现窗体在鼠标左键按住拖动
我把标题栏去掉了,只剩下个窗体,我自己加了个面板在上面作出了关闭和最小化,但是却无法拖动窗体,请问要怎么才能实现啊...
我把标题栏去掉了,只剩下个窗体,我自己加了个面板在上面作出了关闭和最小化,但是却无法拖动窗体,请问要怎么才能实现啊
展开
1个回答
展开全部
Point mouse_offset;
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
mouse_offset = new Point(-e.X, -e.Y);
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
Location = mousePos;
}
}
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
mouse_offset = new Point(-e.X, -e.Y);
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
Location = mousePos;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询