EventArgs e) { Application.Exit(); } private void pictureBo

时间:2021-11-23 02:20:57

在C# WinForm中,边框不显示就会造成窗体无法拖动的情况,把下边的代码添加上去就可以解决。

1.导入定名空间
using System.Runtime.InteropServices;
2.输入如下代码


[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private void pictureBox2_Click(object sender, EventArgs e)
{
    Application.Exit();
}

private void pictureBox4_Click(object sender, EventArgs e)
{
    this.WindowState = FormWindowState.Minimized;
}
在窗体的MouseDown事件中编写如下代码
private void zcmmForm_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        ReleaseCapture(); SendMessage(Handle, 0xA1, 0x02, 0);
    }
}

窗体去失边框后不能拖动的问题

标签:

原文地点:https://www.cnblogs.com/-s11900085/p/8981609.html