惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
G
Google Developers Blog
H
Help Net Security
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
D
Docker
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
博客园 - 司徒正美
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence

博客园 - andyran

xp下多站点及asp.net mvc3配置 获取Controller.ModelState中的所有错误信息 CSS line-height:XX在IE7下面与IE6、IE8、FireFox高度不一样 HRESULT:0x80070057 (E_INVALIDARG)的异常的解决方案 css中div高度自适应的方法(兼容FF IE) Win7安装SQL2005的IIS7设置 CSS兼容与标准,HACK技巧 - andyran - 博客园 通过jquery选择li菜单实现无刷新css效果 - andyran - 博客园 .NET打包安装MSDE以及安装和卸载 为FCKEDITOR添加导入Word文档功能 PEAR之DB_DataObject快速安装 SVN使用技巧 - 不要把不必要的文件版本化 svn架设快速入门(转) utf8的bom问题 Flex中的拖放(Drag-Drop)事件入门 续:使用FLEX为上传的图片添加水印 使用FLEX实现简单WEB在线拍照功能 使用jQuery编写一个UBB编辑器 编写jQuery插件来扩展checkbox
c#实现随鼠标移动窗体
andyran · 2007-12-05 · via 博客园 - andyran

  先声明

1private Point mousePoint;

 1        private void Form1_MouseMove(object sender, MouseEventArgs e)
 2        {            
 3            if (e.Button == MouseButtons.Left)
 4            {
 5                this.Top = Control.MousePosition.Y - mousePoint.Y;
 6                this.Left = Control.MousePosition.X - mousePoint.X;
 7            }

 8        }

 9
10        private void Form1_MouseDown(object sender, MouseEventArgs e)
11        {
12            if (e.Button == MouseButtons.Left)
13            {
14                this.mousePoint.X = e.X;
15                this.mousePoint.Y = e.Y;
16            }

17        }

如果窗体有标题
Top -= SystemInformation.CaptionHeight;

如果有边框
Top -= SystemInformation.FormBorderSize.Height
Left -= SystemInformation.FormBorderSize.Width

andyran