码迷,mamicode.com
首页 > Windows程序 > 详细

winform-实现类似QQ停靠桌面上边缘隐藏的效果

时间:2014-11-18 23:33:07      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:winform   style   blog   io   ar   color   os   sp   for   

 //实现类似QQ停靠桌面上边缘隐藏的效果!
        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窗体隐藏到屏幕的顶端 
        }
   class Win32API
    {
        [DllImport("User32.dll")]
        public static extern bool PtInRect(ref Rectangle r, Point p);
    }

 

winform-实现类似QQ停靠桌面上边缘隐藏的效果

标签:winform   style   blog   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/MrZivChu/p/qqhide.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!