Winform 无边框窗体双击放大缩小
程序员文章站
2022-05-06 08:10:06
...
废话不多说,直接上代码(talk is cheap,show me the code)
[DllImport("user32.dll")] //Namespace System.Runtime.InteropServices;
public static extern bool ReleaseCapture(); //release the mouse capture from a window in the current thread
//Send the specified message to a window,
//The SendMessage fuction calls the window procedure for the specified window and dose not return until the window procedure has processed the message
[DllImport("user32.dll")]
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MAXIMIZE = 0xF030;
public const int SC_RESTORE = 0xF120;
private void btn_title_MouseDown(object sender, MouseEventArgs e)
{
if (e.Clicks == 2)
{
if (WindowState == FormWindowState.Maximized)
{
// Restore the form
ReleaseCapture();
SendMessage(Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
}
else if (WindowState == FormWindowState.Normal)
{
//Maximize the form
ReleaseCapture();
SendMessage(Handle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
}
上一篇: Spring Cloud:Cloud Bootstrap
下一篇: java 获得网络资源
推荐阅读