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

推荐订阅源

T
Threat Research - Cisco Blogs
博客园 - 聂微东
小众软件
小众软件
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
罗磊的独立博客
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
S
Security @ Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
月光博客
月光博客
S
Secure Thoughts
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
W
WeLiveSecurity
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
L
LangChain Blog
T
The Blog of Author Tim Ferriss
NISL@THU
NISL@THU
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Project Zero
Project Zero
SecWiki News
SecWiki News
爱范儿
爱范儿
The Register - Security
The Register - Security
AI
AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
L
Lohrmann on Cybersecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
J
Java Code Geeks
S
Securelist
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog

博客园 - 风也无奈

事件学习 信息系统需求分析阶段的实践经验之二---如何有效地获得用户需求【转】 信息系统需求分析阶段的实践经验之一---需求分析概述[转] Lambda表达式【转】 C#委托的介绍(delegate、Action、Func、predicate)【转】 “DllRegisterServer的调用失败”问题解决办法 什么是RFID技术 SQL Server集群服务器的优缺点 asp中的ckEditor的详细配置 UTF8转成GB2312乱码问题解决思路 winform更新程序代码 C#开发串口总结,并提炼串口辅助类到公用类库中 SQLXML]FOR XML语法导出XML的易错之处 C#下载功能代码<转> C#通用类库--数字转为人民币汉字大写表示 - 风也无奈 - 博客园 link和@import的区别 - 风也无奈 - 博客园 C#操作word并格式化 Winform中的DataGridView控件内容自动保存《转载》 SQL中获取一个长字符串中某个字符串出现次数的简单方法
C#通用类库--QQ吸附窗体类
风也无奈 · 2010-12-06 · via 博客园 - 风也无奈

不用多说,贴出代码就能看懂!

 1 //类名:EcanQQ
 2 //作用:QQ吸附窗体
 3 //作者:刘典武
 4 //时间:2010-12-01
 5 //用法:添加timer控件,enable设置为true,实例化类EcanQQ qqfrm = new EcanQQ();timer1_Tick时间调用qqfrm.hide_show(this, ref height, timer1);     
 6 
 7 using System;
 8 using System.Collections.Generic;
 9 using System.Text;
10 using System.Windows.Forms;
11 
12 namespace Ecan
13 {
14     public class EcanQQ
15     {
16         /// <summary>
17         /// QQ吸附窗体
18         /// </summary>
19         /// <param name="frm">要吸附边缘的窗体</param>
20         /// <param name="frmHeight">窗体的高度</param>
21         /// <param name="timer">定时器控件</param>
22         //用法:在对应窗体timer控件的Tick事件中写代码 int height = this.Height; EcanQQ.hide_show(this, ref height, timer1);
23         
24         public void hide_show(Form frm, ref int frmHeight, Timer timer)
25         {
26             if (frm.WindowState != FormWindowState.Minimized)
27             {
28                 timer.Interval = 100;                
29                 if (Cursor.Position.X > frm.Left - 1 && Cursor.Position.X < frm.Right && Cursor.Position.Y > frm.Top - 1 && Cursor.Position.Y < frm.Bottom)
30                 {
31                     if (frm.Top <= 0 && frm.Left > 5 && frm.Left < Screen.PrimaryScreen.WorkingArea.Width - frm.Width)
32                     {
33                         frm.Top = 0;
34                     }
35                     else if (frm.Left <= 0)
36                     {
37                         frm.Left = 0;
38                     }
39                     else if (frm.Left + frm.Width > Screen.PrimaryScreen.WorkingArea.Width)
40                     {
41                         frm.Left = Screen.PrimaryScreen.WorkingArea.Width - frm.Width;
42                     }
43                     else
44                     {
45                         if (frmHeight > 0)
46                         {
47                             frm.Height = frmHeight;
48                             frmHeight = 0;
49                         }
50                     }
51                 }
52                 else
53                 {
54                     if (frmHeight < 1)
55                     {
56                         frmHeight = frm.Height;
57                     }
58                     if (frm.Top <= 4 && frm.Left > 5 && frm.Left < Screen.PrimaryScreen.WorkingArea.Width - frm.Width)
59                     {
60                         frm.Top = 3 - frm.Height;
61                         if (frm.Left <= 4)
62                         {
63                             frm.Left = -5;
64                         }
65                         else if (frm.Left + frm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
66                         {
67                             frm.Left = Screen.PrimaryScreen.WorkingArea.Width - frm.Width + 5;
68                         }
69                     }
70                     else if (frm.Left <= 4)
71                     {
72                         frm.Left = 3 - frm.Width;
73                     }
74                     else if (frm.Left + frm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
75                     {
76                         frm.Left = Screen.PrimaryScreen.WorkingArea.Width - 3;
77                     }
78                 }
79             }
80         }
81     }
82 }
83 

效果:窗体移动到屏幕边缘会自动伸缩,鼠标移上去的话就显示出来!