winform 窗体属性FormBorderStyle 为none时使窗体可以被移动
2017-11-15 09:40
519 查看
我们在做winform开发时 会觉得窗体的 最大化 关闭等按钮很丑 这时我们就会把窗体的属性FormBorderStyle设置为None 从而自定义按钮 但此时 窗体就不能够被移动了
下面贴一下 可以移动的代码
第一步:在程序中添加以下代码
·#region 使窗体可以移动的代码
[DllImport(“user32.dll”)]
public static extern bool ReleaseCapture();
[DllImport(“user32.dll”)]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
·#endregion
第二步:在窗体的Mouse_Down事件中调用
private void Main_MouseDown(object sender, MouseEventArgs e)
{
//拖动窗体
this.Cursor = System.Windows.Forms.Cursors.Hand;//改变鼠标样式
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
this.Cursor = System.Windows.Forms.Cursors.Default;
}
OK了 窗体可以移动了
原文链接:http://blog.csdn.net/everlasting51/article/details/16827273
下面贴一下 可以移动的代码
第一步:在程序中添加以下代码
·#region 使窗体可以移动的代码
[DllImport(“user32.dll”)]
public static extern bool ReleaseCapture();
[DllImport(“user32.dll”)]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
·#endregion
第二步:在窗体的Mouse_Down事件中调用
private void Main_MouseDown(object sender, MouseEventArgs e)
{
//拖动窗体
this.Cursor = System.Windows.Forms.Cursors.Hand;//改变鼠标样式
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
this.Cursor = System.Windows.Forms.Cursors.Default;
}
OK了 窗体可以移动了
原文链接:http://blog.csdn.net/everlasting51/article/details/16827273
相关文章推荐
- winform 窗体属性FormBorderStyle 为none时使窗体可以被移动
- Winform无边框窗体(FormBorderStyle属性设为None)自定义移动
- Winform 设置formborderStyle 为None后如何移动窗体
- C#中form的窗体属性formborderstyle设置为none后就不能移动了
- 拖动窗体FormBorderStyle属性为None的窗体移动
- Winform 设置formborderStyle 为None后如何移动窗体
- C#:form的窗体属性formborderstyle设置为none后就不能移动了
- 点击任务栏图标让窗体可以隐藏或显示(FormBorderStyle设置为None)
- FormBorderStyle设为None,移动Winform窗口的两种方法
- WinForm设置FormBorderStyle=none后仍可以使用任务栏左键和右键功能
- FormBorderStyle设为None,移动Winform窗口的两种方法
- FormBorderStyle设为None,移动Winform窗口的两种方法
- C#自定义窗体(不设置FormBorderStyle=none)
- winfrom属性formborderstyle:none以后
- 测试窗体的FormBorderStyle属性,不同属性所对应的窗体边框显示情况
- Form(窗体)的FormBorderStyle属性的不同效果
- FormBorderStyle为None时拖动窗体
- FormBorderStyle.None时,支持改变窗体大小
- (WinForm)FormBorderStyle属性
- WinForm 代码设置FormBorderStyle的属性