FormBorderStyle为None的时候如何拖动窗体
//为DllImport导出命名空间,
using System.Runtime.InteropServices;
public partial class Form1 : System.Windows.Forms.Form
{
#region FormBorderStyle为None,拖放窗体
[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;
private void Form_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, );
}
#endregion
#region 构造函数
public Form1()
{
//初始化窗体信息
//InitializeComponent();
//绑定鼠标拖动窗体事件
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
}
#endregion
}
参考:
FormBorderStyle为None的时候如何拖动窗体的更多相关文章
- 拖动窗体FormBorderStyle属性为None的窗体移动
winform窗体的样式很单一,不够漂亮,往往我们需要对窗体进行重写,但是我们又要保留在重写前窗体本身带的功能,例如拖动窗体的头进行移动之类的. 一下方式可以实现该方法: [DllImport(&qu ...
- MFC 无边框窗体实现用鼠标拖动窗体边缘实现窗体大小变化
无边框窗体如何实现用鼠标拖动窗体边缘实现窗体大小变动呢?下面介绍一种方法,通过以下几个步骤即可实现: 1.实现WM_NCHITTEST消息,实现四条边框的模拟 2.实现WM_NCLBUTTONDOWN ...
- c# 鼠标点击控件即拖动窗体
在编程中,有时打开的窗体没有边框,但是我们仍然想在鼠标放在窗体上就能拖动窗体,这样我们只需要以窗体中的一个控件为参考,我们在这里以panel为例子: public class PanelNew : P ...
- WPF无边框可拖动窗体
下面主要记录下创建无边框窗体,并且可以拖动.这种窗体主要用于弹出小窗体时. <Window x:Class="WpfApplication1.MainWindow" xmln ...
- winform学习(9)无边框拖动窗体
去除边框 选中窗体,在属性中找到FormBorderStyle,设置为None 实现无边框拖动 [DllImport("user32.dll")] public st ...
- 在Window工作区按下鼠标左键拖动窗体
Window.DragMove(): 允许使用在窗口工作区的暴露区域上方按下其鼠标左键的鼠标来拖动窗口.(窗口工作区:除去窗体的title.bottom后的剩余部分空间) 使用该方法时注意:一定要在鼠 ...
- C#在窗体中按下鼠标键拖动窗体
[DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); [DllImport ...
- 当winform窗体的Bordestyle设置为None时,鼠标可以拖动窗体的办法
方法一: 1 2015-07-11 16:05:35 Point formPoint;//记录窗体的位置 private void Form1_MouseDown(object sender, Mou ...
- winform 点击控件拖动窗体
private Point mPoint = new Point(); private void 选择控件_MouseDown(object sender, MouseEventArgs e) { m ...
随机推荐
- Java 深入浅出String
String String是一个被final修饰的类,直接继承于Object,同时也实现了charsequence接口,String被声明为final也就不可以被继承了.由于String的方法比较多, ...
- Django+Nginx+uwsgi搭建自己的博客(六)
这篇应该是2017年的最后一篇博客了,在这里首先祝大家元旦快乐! 从这篇博客开始,将会介绍Blogs App的功能实现,包括数据模型的建立.相关功能的视图函数的实现.前端页面的设计等,这意味着我们即将 ...
- DateFormat 线程安全
SimpleDateformat 线程不安全 SimpleDateFormat 继承自 DateFormat, SimpleDateFormat中的parse方法override父类DateForma ...
- 应用服务攻击工具clusterd
应用服务攻击工具clusterd clusterd是一款Python语言编写的开源应用服务攻击工具.该工具支持七种不同的应用服务平台,如JBoss.ColdFusion.WebLogic.Tomc ...
- 范浩强treap 普通平衡树
增加Split(分裂),Merge(合并)操作,非常好写,时间也不比普通treap慢什么. #include<bits/stdc++.h> using namespace std; str ...
- BZOJ 4516: [Sdoi2016]生成魔咒 后缀自动机 性质
http://www.lydsy.com/JudgeOnline/problem.php?id=4516 http://blog.csdn.net/doyouseeman/article/detail ...
- Java并发(八):AbstractQueuedSynchronizer
先做总结: 1.AbstractQueuedSynchronizer是什么? AbstractQueuedSynchronizer(AQS)这个抽象类,是Java并发包 java.util.concu ...
- HDU 4183
给出一个有向图,以及src和dst.判断是否存在从src到dst的两条路径,使得除了src和dst外,没有其它点同时属于两条路径. 给每个点一个为1的点容量(src和dst为2),边的容量也是1,然后 ...
- Linux下Apache2.2和PHP5的安装配置
Linux下Apache2.2和PHP5的安装配置 环境介绍 我安装使用的Linux版本为CentOS6.5最精简版,Apache为2.2.29,PHP版本为5.4.28. 系统安装 首先安装Cent ...
- Codeforces Round #346 (Div. 2) D. Bicycle Race 叉积
D. Bicycle Race 题目连接: http://www.codeforces.com/contest/659/problem/D Description Maria participates ...