winform 窗体属性FormBorderStyle 为none时使窗体可以被移动
来源:互联网 发布:快速买火车票软件 编辑:程序博客网 时间:2024/05/18 03:13
我们在做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了 窗体可以移动了
- winform 窗体属性FormBorderStyle 为none时使窗体可以被移动
- winform 窗体属性FormBorderStyle 为none时使窗体可以被移动
- FormBorderStyle为None时拖动窗体
- Winform FormBorderStyle.None时,支持改变窗体大小
- FormBorderStyle.None时,支持改变窗体大小
- 点击任务栏图标让窗体可以隐藏或显示(FormBorderStyle设置为None)
- 当winform窗体的Bordestyle设置为None时,鼠标可以拖动窗体的办法
- 003.将窗体设置为固定大小属性FormBorderStyle
- FormBorderStyle设为None,移动Winform窗口的两种方法
- FormBorderStyle设为None,移动Winform窗口的两种方法
- Winform 无标题栏可以移动窗体
- 通过计算窗体工作区来模拟FormBorderStyle=None
- Winform 窗体移动
- C# WinForm窗体的TopMost属性设置为true时,多次点击窗体弹出事件,只会弹出一个窗体
- winform窗体属性设置
- winform 窗体属性
- Form(窗体)的FormBorderStyle属性的不同效果
- Form(窗体)的FormBorderStyle属性的不同效果
- Windows Store 平台移植 —— (5) 补充线程相关 API
- linux系统文件的深入理解
- ubuntu 命令行基础,用户管理学习完了
- linux paste简单用法
- Xenomai安装
- winform 窗体属性FormBorderStyle 为none时使窗体可以被移动
- Windows Store 平台移植 —— (6) 补充网络 API
- Linux下的多线程编程
- java非常有用的代码段(关键时候可以看看)
- pyside-lupdate 解析问题
- perl哈希hash的常见用法介绍
- Run iOS Simulator from the Command Line (runsim)
- Windows Store 平台移植 —— (7) 网络 API
- SGU 117Counting(快速幂)