本文主要是介绍Winform 使用panel 自定义拖动窗体,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
Common.FromCustomStyle.MoveForm(this, this.panel1);
}
///<summary>
///拖动Panel 窗体移动
///</summary>
///<param name="form1">窗口实例</param>
///<param name="panel1">要拖动的Panel</param>
public static void MoveForm(Form form1,System.Windows.Forms.Panel panel1)
{
ReleaseCapture();
SendMessage(form1.Handle,WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);//*********************调用移动无窗体控件函数
}
//定义无边框窗体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);
public const int WM_SYSCOMMAND =0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
这篇关于Winform 使用panel 自定义拖动窗体的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!