基本信息
源码名称:c# 吸附窗体类,仿QQ效果
源码大小:3.21KB
文件格式:.cs
开发语言:C#
更新时间:2013-12-31
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
窗体移动到屏幕边缘会自动伸缩,鼠标移上去的话就显示出来!
窗体移动到屏幕边缘会自动伸缩,鼠标移上去的话就显示出来!
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace Ecan { public class EcanQQ { /// <summary> /// QQ吸附窗体 /// </summary> /// <param name="frm">要吸附边缘的窗体</param> /// <param name="frmHeight">窗体的高度</param> /// <param name="timer">定时器控件</param> //用法:在对应窗体timer控件的Tick事件中写代码 int height = this.Height; EcanQQ.hide_show(this, ref height, timer1); public void hide_show(Form frm, ref int frmHeight, Timer timer) { if (frm.WindowState != FormWindowState.Minimized) { timer.Interval = 100; if (Cursor.Position.X > frm.Left - 1 && Cursor.Position.X < frm.Right && Cursor.Position.Y > frm.Top - 1 && Cursor.Position.Y < frm.Bottom) { if (frm.Top <= 0 && frm.Left > 5 && frm.Left < Screen.PrimaryScreen.WorkingArea.Width - frm.Width) { frm.Top = 0; } else if (frm.Left <= 0) { frm.Left = 0; } else if (frm.Left frm.Width > Screen.PrimaryScreen.WorkingArea.Width) { frm.Left = Screen.PrimaryScreen.WorkingArea.Width - frm.Width; } else { if (frmHeight > 0) { frm.Height = frmHeight; frmHeight = 0; } } } else { if (frmHeight < 1) { frmHeight = frm.Height; } if (frm.Top <= 4 && frm.Left > 5 && frm.Left < Screen.PrimaryScreen.WorkingArea.Width - frm.Width) { frm.Top = 3 - frm.Height; if (frm.Left <= 4) { frm.Left = -5; } else if (frm.Left frm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4) { frm.Left = Screen.PrimaryScreen.WorkingArea.Width - frm.Width 5; } } else if (frm.Left <= 4) { frm.Left = 3 - frm.Width; } else if (frm.Left frm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4) { frm.Left = Screen.PrimaryScreen.WorkingArea.Width - 3; } } } } } }