仿QQ会员右下角提示框c#实现

来源:互联网 发布:阿里云 ecs 是iaas 编辑:程序博客网 时间:2024/04/29 23:38
为了不让大家再误会,我在这里声明,我做的是在登录后的提示,只要大家用过QQ,Q会员开通过就知道 的,
先看一下效果吧


说一下实现 吧,

第一步是先把QQ会员 便当 的框给截图下来,然后放到Ps里P一下,需要做到这样就行了,看图片


第二步,可以在上面加一 些Lable就行了,关闭按钮是两个图片,切换的方法是这样的 

privatevoid pictureBox1_MouseLeave(objectsender, EventArgs e)
{
    pictureBox1.BackgroundImage = ClientSystem.Properties.Resources.lgintop;
}
 
//图片进入事件
privatevoid pictureBox1_MouseEnter(objectsender, EventArgs e)
{
    pictureBox1.BackgroundImage = ClientSystem.Properties.Resources.lgintop1;
}

第三步,IP的取法我就不说了有很多,还有上面的4.0的测试这些都 是加上的新闻,只要启动浏览器就行了,
启动的方法是

//系统官网
        privatevoid label7_Click(objectsender, EventArgs e)
        {
            Process.Start("http//www.cckan.net/");
        }[/code]
 
第四步,说一下渐变显示 的效果的处理方法
[mw_shl_code=csharp,true]代码
//界面加载
        privatevoid Messages_Load(objectsender, EventArgs e)
        {
            try
            {
                //让窗体加载时显示到右下角
                intx = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 255;
                inty = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - 161;
                this.SetDesktopLocation(x, y);
 
                //加载显示信息
                ShowComptureInfo();
 
                //渐变显示这里表示加载
                caozuo = "load";
                this.Opacity = 0;
            }
            catch(Exception)
            {
 
            }
        }
caozuo有两个值一个是 load表示要向不透明方向增加量,也就是说会慢慢看清楚,还有一个close 表示要向透明方向增加量,这样会慢慢的看不到窗体,我是用一个Timer来处理的

//定时处理渐变的效果
        privatevoid timer2_Tick(objectsender, EventArgs e)
        {
            if(caozuo == "load")
            {
                this.Opacity += 0.09;
            }
            elseif (caozuo == "close")
            {
                this.Opacity = this.Opacity - 0.09;
                if(this.Opacity == 0)
                    this.Close();
            }
        }
这样只要caozuo的值发生变化的时候 就会向某个方向开始增加渐变显示 的量
当鼠标进入的时候我是这样处理的

//进入窗体事件
        privatevoid Messages_MouseEnter(objectsender, EventArgs e)
        {
            //停止定时关闭
            timer1.Enabled = false;
            //开始渐变加载
            caozuo = "load";
        }
这样的话就会在原来的基础上加量,也就是说如果快不显示了,当鼠标移动进入窗体时就双会慢慢的显示,当移开的时候我是这样处理的

//窗体离开事件
        privatevoid Messages_MouseLeave(objectsender, EventArgs e)
        {
            timer1.Enabled = true;
        }
 
  //定时关闭窗体
        privatevoid timer1_Tick(objectsender, EventArgs e)
        {
            timer2.Enabled = true;
            caozuo = "close";//关闭窗体
        }
这样就双会启动定时关闭窗体,我的定时是6秒大家可以随便改的效果就是这样实现的
因为我的窗体 是没有标题栏的这样就不能拖动了, 很不方便,拖动窗体的方法有很多,我是这样实现 的,

privatebool isMouseDown = false;
        privatePoint FormLocation;     //form的location
        privatePoint mouseOffset;      //鼠标的按下位置
 
        //鼠标安下
        privatevoid Messages_MouseDown(objectsender, MouseEventArgs e)
        {
            try
            {
                if(e.Button == MouseButtons.Left)
                {
                    isMouseDown = true;
                    FormLocation = this.Location;
                    mouseOffset = Control.MousePosition;
                }
            }
            catch(Exception)
            {
 
            }
        }
 
        //鼠标移动
        privatevoid Messages_MouseMove(objectsender, MouseEventArgs e)
        {
            try
            {
                int_x = 0;
                int_y = 0;
                if(isMouseDown)
                {
                    Point pt = Control.MousePosition;
                    _x = mouseOffset.X - pt.X;
                    _y = mouseOffset.Y - pt.Y;
 
                    this.Location = newPoint(FormLocation.X - _x, FormLocation.Y - _y);
                }
            }
            catch(Exception)
            {
 
            }
        }
 
        //鼠标松开
        privatevoid Messages_MouseUp(objectsender, MouseEventArgs e)
        {
            try
            {
                isMouseDown = false;
            }
            catch(Exception)
            {
 
            }
        }
关于这个内容 可以参考 我的文章
拖动无标题窗体的方法
http://www.cckan.net/forum.php?mod=viewthread&tid=68
using System;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingClientSystem.ClientSystemServices;
usingBaseFunction;
usingSystem.Diagnostics;
 
namespaceClientSystem
{
    /// <summary>
    /// 提示窗体  苏飞
    /// </summary>
    publicpartial class Messages : Form
    {
        publicMessages()
        {
            InitializeComponent();
        }
        //营业厅完整信息
        publicOfficeInfo OfficeInfo { get;set; }
 
        #region //私有变量和方法
 
        privateClientSystemServices.Service1SoapClient user = newService1SoapClient();
 
        //显示登录用户的计算机信息
        publicvoid ShowComptureInfo()
        {
            //CUP
            //label9.Text = ComputerInfo.GetCpuID();
 
            //硬盘
            //label26.Text = ComputerInfo.GetDiskID();
 
            //IP
            lblIP.Text = ComputerInfo.GetIPAddress();
 
            //上次登录IP
            lbloldIP.Text = ComputerInfo.GetIPAddress();
 
            //用户名
            lblUser.Text = OfficeInfo.ofLogin + " 商户欢迎您";
 
            //计算机名称
            //label21.Text = ComputerInfo.GetComputerName();
 
            //操作系统
            //label23.Text = ComputerInfo.GetSystemType();
 
            //当前用户
            //label25.Text = ComputerInfo.GetUserName();
        }
 
        #endregion
 
        //界面加载
        privatevoid Messages_Load(objectsender, EventArgs e)
        {
            try
            {
                //让窗体加载时显示到右下角
                intx = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 255;
                inty = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - 161;
                this.SetDesktopLocation(x, y);
 
                //加载显示信息
                ShowComptureInfo();
 
                //渐变显示这里表示加载
                caozuo = "load";
                this.Opacity = 0;
            }
            catch(Exception)
            {
 
            }
        }
 
        //关闭按钮
        privatevoid pictureBox1_Click(objectsender, EventArgs e)
        {
            this.Close();
        }
 
        //图片离开事件
        privatevoid pictureBox1_MouseLeave(objectsender, EventArgs e)
        {
            pictureBox1.BackgroundImage = ClientSystem.Properties.Resources.lgintop;
        }
 
        //图片进入事件
        privatevoid pictureBox1_MouseEnter(objectsender, EventArgs e)
        {
            pictureBox1.BackgroundImage = ClientSystem.Properties.Resources.lgintop1;
        }
 
        //修改密码
        privatevoid label6_Click(objectsender, EventArgs e)
        {
            ChangePwd frm = newChangePwd();
            frm.OfficeInfo = this.OfficeInfo;
            frm.Show();
        }
 
        //系统官网
        privatevoid label7_Click(objectsender, EventArgs e)
        {
            Process.Start("http://www.smxzc.com/");
        }
 
        #region//拖动无标题窗体
 
        privatebool isMouseDown = false;
        privatePoint FormLocation;     //form的location
        privatePoint mouseOffset;      //鼠标的按下位置
 
        //鼠标安下
        privatevoid Messages_MouseDown(objectsender, MouseEventArgs e)
        {
            try
            {
                if(e.Button == MouseButtons.Left)
                {
                    isMouseDown = true;
                    FormLocation = this.Location;
                    mouseOffset = Control.MousePosition;
                }
            }
            catch(Exception)
            {
 
            }
        }
 
        //鼠标移动
        privatevoid Messages_MouseMove(objectsender, MouseEventArgs e)
        {
            try
            {
                int_x = 0;
                int_y = 0;
                if(isMouseDown)
                {
                    Point pt = Control.MousePosition;
                    _x = mouseOffset.X - pt.X;
                    _y = mouseOffset.Y - pt.Y;
 
                    this.Location = newPoint(FormLocation.X - _x, FormLocation.Y - _y);
                }
            }
            catch(Exception)
            {
 
            }
        }
 
        //鼠标松开
        privatevoid Messages_MouseUp(objectsender, MouseEventArgs e)
        {
            try
            {
                isMouseDown = false;
            }
            catch(Exception)
            {
 
            }
        }
        #endregion
 
        //定时关闭窗体
        privatevoid timer1_Tick(objectsender, EventArgs e)
        {
            timer2.Enabled = true;
            caozuo = "close";//关闭窗体
        }
 
        //进入窗体事件
        privatevoid Messages_MouseEnter(objectsender, EventArgs e)
        {
            //停止定时关闭
            timer1.Enabled = false;
            //开始渐变加载
            caozuo = "load";
        }
 
        //窗体离开事件
        privatevoid Messages_MouseLeave(objectsender, EventArgs e)
        {
            timer1.Enabled = true;
        }
 
        stringcaozuo = "";
 
        //定时处理渐变的效果
        privatevoid timer2_Tick(objectsender, EventArgs e)
        {
            if(caozuo == "load")
            {
                this.Opacity += 0.09;
            }
            elseif (caozuo == "close")
            {
                this.Opacity = this.Opacity - 0.09;
                if(this.Opacity == 0)
                    this.Close();
            }
        }
    }
}

0 0