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

为了不让大家再误会,我在这里声明,我做的是在登录后的提示,只要大家用过QQ,Q会员开通过就知道 的,
先看一下效果吧


说一下实现 吧,

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


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

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

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

//系统官网
         private void label7_Click( object sender, EventArgs e)
         {
             Process.Start( "http//www.cckan.net/" );
         }[/code]
 
第四步,说一下渐变显示 的效果的处理方法
[mw_shl_code=csharp, true ]代码
//界面加载
         private void Messages_Load( object sender, EventArgs e)
         {
             try
             {
                 //让窗体加载时显示到右下角
                 int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 255;
                 int y = 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来处理的

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

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

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

private bool isMouseDown = false ;
         private Point FormLocation;     //form的location
         private Point mouseOffset;      //鼠标的按下位置
 
         //鼠标安下
         private void Messages_MouseDown( object sender, MouseEventArgs e)
         {
             try
             {
                 if (e.Button == MouseButtons.Left)
                 {
                     isMouseDown = true ;
                     FormLocation = this .Location;
                     mouseOffset = Control.MousePosition;
                 }
             }
             catch (Exception)
             {
 
             }
         }
 
         //鼠标移动
         private void Messages_MouseMove( object sender, 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 = new Point(FormLocation.X - _x, FormLocation.Y - _y);
                 }
             }
             catch (Exception)
             {
 
             }
         }
 
         //鼠标松开
         private void Messages_MouseUp( object sender, MouseEventArgs e)
         {
             try
             {
                 isMouseDown = false ;
             }
             catch (Exception)
             {
 
             }
         }
关于这个内容 可以参考 我的文章
拖动无标题窗体的方法
http://www.cckan.net/forum.php?mod=viewthread&tid=68
using  System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClientSystem.ClientSystemServices;
using BaseFunction;
using System.Diagnostics;
 
namespace ClientSystem
{
     /// <summary>
     /// 提示窗体  苏飞
     /// </summary>
     public partial class Messages : Form
     {
         public Messages()
         {
             InitializeComponent();
         }
         //营业厅完整信息
         public OfficeInfo OfficeInfo { get ; set ; }
 
         #region //私有变量和方法
 
         private ClientSystemServices.Service1SoapClient user = new Service1SoapClient();
 
         //显示登录用户的计算机信息
         public void 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
 
         //界面加载
         private void Messages_Load( object sender, EventArgs e)
         {
             try
             {
                 //让窗体加载时显示到右下角
                 int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 255;
                 int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - 161;
                 this .SetDesktopLocation(x, y);
 
                 //加载显示信息
                 ShowComptureInfo();
 
                 //渐变显示这里表示加载
                 caozuo = "load" ;
                 this .Opacity = 0;
             }
             catch (Exception)
             {
 
             }
         }
 
         //关闭按钮
         private void pictureBox1_Click( object sender, EventArgs e)
         {
             this .Close();
         }
 
         //图片离开事件
         private void pictureBox1_MouseLeave( object sender, EventArgs e)
         {
             pictureBox1.BackgroundImage = ClientSystem.Properties.Resources.lgintop;
         }
 
         //图片进入事件
         private void pictureBox1_MouseEnter( object sender, EventArgs e)
         {
             pictureBox1.BackgroundImage = ClientSystem.Properties.Resources.lgintop1;
         }
 
         //修改密码
         private void label6_Click( object sender, EventArgs e)
         {
             ChangePwd frm = new ChangePwd();
             frm.OfficeInfo = this .OfficeInfo;
             frm.Show();
         }
 
         //系统官网
         private void label7_Click( object sender, EventArgs e)
         {
             Process.Start( "http://www.smxzc.com/" );
         }
 
         #region//拖动无标题窗体
 
         private bool isMouseDown = false ;
         private Point FormLocation;     //form的location
         private Point mouseOffset;      //鼠标的按下位置
 
         //鼠标安下
         private void Messages_MouseDown( object sender, MouseEventArgs e)
         {
             try
             {
                 if (e.Button == MouseButtons.Left)
                 {
                     isMouseDown = true ;
                     FormLocation = this .Location;
                     mouseOffset = Control.MousePosition;
                 }
             }
             catch (Exception)
             {
 
             }
         }
 
         //鼠标移动
         private void Messages_MouseMove( object sender, 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 = new Point(FormLocation.X - _x, FormLocation.Y - _y);
                 }
             }
             catch (Exception)
             {
 
             }
         }
 
         //鼠标松开
         private void Messages_MouseUp( object sender, MouseEventArgs e)
         {
             try
             {
                 isMouseDown = false ;
             }
             catch (Exception)
             {
 
             }
         }
         #endregion
 
         //定时关闭窗体
         private void timer1_Tick( object sender, EventArgs e)
         {
             timer2.Enabled = true ;
             caozuo = "close" ; //关闭窗体
         }
 
         //进入窗体事件
         private void Messages_MouseEnter( object sender, EventArgs e)
         {
             //停止定时关闭
             timer1.Enabled = false ;
             //开始渐变加载
             caozuo = "load" ;
         }
 
         //窗体离开事件
         private void Messages_MouseLeave( object sender, EventArgs e)
         {
             timer1.Enabled = true ;
         }
 
         string caozuo = "" ;
 
         //定时处理渐变的效果
         private void timer2_Tick( object sender, EventArgs e)
         {
             if (caozuo == "load" )
             {
                 this .Opacity += 0.09;
             }
             else if (caozuo == "close" )
             {
                 this .Opacity = this .Opacity - 0.09;
                 if ( this .Opacity == 0)
                     this .Close();
             }
         }
     }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值