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 ...
随机推荐
- 转:VMMAP内存查看工具
转:http://blog.csdn.net/woddle/article/details/45337767 下面我根据VMMap来详细介绍一下内存的分类. 内存是一个很复杂的系统,其中的paging ...
- learn_requests
# -*- coding: utf-8 -*- import requests URL_IP = 'http://localhost:8000/ip' URL_GET = 'http://localh ...
- JSP内置对象——request对象
request对象request对象封装了由客户端生成的HTTP请求的所有细节,主要包括HTTP头信息.系统信息.请求方式和请求参数等. 通过request对象提供的各种方法可以处理客户端浏览器提交的 ...
- java反射,代码优化
java的反射机制属实强大,能解决好些问题 在接手别人写的代码的时候,有一个bean类的get方法特别low,我都看不下去 重复代码写五遍,我都觉得太不合理.之后将其中代码抽取出来修改了下. publ ...
- zTree通过指定ID找到节点并选中
zTree = $.fn.zTree.getZTreeObj("treeDemo");//treeDemo界面中加载ztree的div var node = zTree.getNo ...
- Chris and Magic Square CodeForces - 711B
ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid o ...
- BeautifulSoup解析库
解析库 解析器 使用方法 优势 劣势 Python标准库 BeautifulSoup(html, 'html.parser') 速度适中,容错能力强 老版本python容错能力差 lxml HTML解 ...
- [BZOJ2427][HAOI2010]软件安装(Tarjan+DP)
2427: [HAOI2010]软件安装 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1987 Solved: 791[Submit][Statu ...
- 安装myeclipse的常见问题
1.破解myeclipse网站: https://jingyan.baidu.com/article/acf728fd49519ff8e410a361.html
- python开发_textwrap文本样式
在看python的API的时候,发现python的textwrap在处理字符串样式的时候功能强大 在这里我做了一个demo: textwrap提供了一些方法: wrap(text, width = 7 ...