winFrom窗口特效 请问有什么方法可以让窗口靠边隐藏 类似于QQ等窗口的特效 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/sunchaohuang/archive/2009/02/18/3903682.aspx 这个原理比较简单。使用一个timer控件,定时获取当前鼠标的位置,如果鼠标的位置不在屏幕内,则将窗体进行隐藏。代码如下: #region 窗体隐藏 class Win32API { [DllImport("User32.dll")] public static extern bool PtInRect(ref Rectangle r, Point p); } private void timer1_Tick(object sender, EventArgs e) { System.Drawing.Point pp=new Point(Cursor.Position.X,Cursor.Position.Y);//获取鼠标在屏幕的坐标点 Rectangle Rects = new Rectangle(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);//存储当前窗体在屏幕的所在区域 if ((this.Top < 0) && Win32API.PtInRect(ref Rects, pp))//当鼠标在当前窗体内,并且窗体的Top属性小于0 this.Top = 0;//设置窗体的Top属性为0 else //当窗体的上边框与屏幕的顶端的距离小于5时 if (this.Top > -5 && this.Top < 5 && !(Win32API.PtInRect(ref Rects, pp))) this.Top = 5 - this.Height;//将QQ窗体隐藏到屏幕的顶端 } #endregion public static void SideHideOrShow(Form DockableForm, ref int DockFormHeight, Timer _dockTimer) { if (DockableForm.WindowState != FormWindowState.Minimized) { _dockTimer.Interval = 100; if (Cursor.Position.X > DockableForm.Left - 1 && Cursor.Position.X < DockableForm.Right && Cursor.Position.Y > DockableForm.Top - 1 && Cursor.Position.Y < DockableForm.Bottom) { if (DockableForm.Top <= 0 && DockableForm.Left > 5 && DockableForm.Left < Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width) { DockableForm.Top = 0; } else if (DockableForm.Left <= 0) { DockableForm.Left = 0; } else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width) { DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width; } else { if (DockFormHeight > 0) { DockableForm.Height = DockFormHeight; DockFormHeight = 0; } } } else { if (DockFormHeight < 1) { DockFormHeight = DockableForm.Height; } if (DockableForm.Top <= 4 && DockableForm.Left > 5 && DockableForm.Left < Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width) { DockableForm.Top = 3 - DockableForm.Height; if (DockableForm.Left <= 4) { DockableForm.Left = -5; } else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4) { DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width + 5; } } else if (DockableForm.Left <= 4) { DockableForm.Left = 3 - DockableForm.Width; } else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4) { DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - 3; } _dockTimer.Interval = 100; } } } winfrom中的界面设计怎么弄啊 时间日期转化问题 高手看看!!!!!!!! c# 如何提取字符点阵数据 c# 何如在窗体内部 运行另外一个程序呢? 关于数据库更新问题 Linq如何实现交叉报表!!!!!! 怎样让程序一启动就到托盘? 请大家提供关于用C#开发DCOM的例子、链接等 做博客~帮帮忙吧? about 屏幕键盘 DataGridView控件中修改数据 DataGridView 单元格数据联动问题
class Win32API
{
[DllImport("User32.dll")]
public static extern bool PtInRect(ref Rectangle r, Point p);
}
private void timer1_Tick(object sender, EventArgs e)
{
System.Drawing.Point pp=new Point(Cursor.Position.X,Cursor.Position.Y);//获取鼠标在屏幕的坐标点
Rectangle Rects = new Rectangle(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);//存储当前窗体在屏幕的所在区域
if ((this.Top < 0) && Win32API.PtInRect(ref Rects, pp))//当鼠标在当前窗体内,并且窗体的Top属性小于0
this.Top = 0;//设置窗体的Top属性为0
else
//当窗体的上边框与屏幕的顶端的距离小于5时
if (this.Top > -5 && this.Top < 5 && !(Win32API.PtInRect(ref Rects, pp)))
this.Top = 5 - this.Height;//将QQ窗体隐藏到屏幕的顶端 }
#endregion
{
if (DockableForm.WindowState != FormWindowState.Minimized)
{
_dockTimer.Interval = 100;
if (Cursor.Position.X > DockableForm.Left - 1 && Cursor.Position.X < DockableForm.Right && Cursor.Position.Y > DockableForm.Top - 1 && Cursor.Position.Y < DockableForm.Bottom)
{
if (DockableForm.Top <= 0 && DockableForm.Left > 5 && DockableForm.Left < Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width)
{
DockableForm.Top = 0;
}
else if (DockableForm.Left <= 0)
{
DockableForm.Left = 0;
}
else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width)
{
DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width;
}
else
{
if (DockFormHeight > 0)
{
DockableForm.Height = DockFormHeight;
DockFormHeight = 0;
}
}
}
else
{
if (DockFormHeight < 1)
{
DockFormHeight = DockableForm.Height;
}
if (DockableForm.Top <= 4 && DockableForm.Left > 5 && DockableForm.Left < Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width)
{
DockableForm.Top = 3 - DockableForm.Height;
if (DockableForm.Left <= 4)
{
DockableForm.Left = -5;
}
else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
{
DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - DockableForm.Width + 5;
}
}
else if (DockableForm.Left <= 4)
{
DockableForm.Left = 3 - DockableForm.Width;
}
else if (DockableForm.Left + DockableForm.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
{
DockableForm.Left = Screen.PrimaryScreen.WorkingArea.Width - 3;
}
_dockTimer.Interval = 100;
}
}
}