在c# winform中,怎么做类似msn好友上线提示的探出框,各位帮忙!

解决方案 »

  1.   

    http://www.microsoft.com/china/community/Column/64.mspx
      

  2.   

    codeproject.com
    上面很多这样的东西
      

  3.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace Calendar
    {
    /// <summary>
    /// clew 的摘要说明。
    /// </summary>
    public class clew : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.Timer timer2;
    private System.Windows.Forms.Timer timer3;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.ComponentModel.IContainer components; public clew()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.timer2 = new System.Windows.Forms.Timer(this.components);
    this.timer3 = new System.Windows.Forms.Timer(this.components);
    this.label1 = new System.Windows.Forms.Label();
    this.label2 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // 
    // timer1
    // 
    this.timer1.Interval = 10;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // timer2
    // 
    this.timer2.Interval = 10;
    this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
    // 
    // timer3
    // 
    this.timer3.Interval = 10;
    this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(24, 40);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(152, 96);
    this.label1.TabIndex = 0;
    // 
    // label2
    // 
    this.label2.Location = new System.Drawing.Point(0, 0);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(192, 24);
    this.label2.TabIndex = 1;
    // 
    // clew
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(7, 15);
    this.BackColor = System.Drawing.SystemColors.InactiveCaption;
    this.ClientSize = new System.Drawing.Size(194, 150);
    this.Controls.Add(this.label2);
    this.Controls.Add(this.label1);
    this.Cursor = System.Windows.Forms.Cursors.Hand;
    this.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
    this.MaximizeBox = false;
    this.MinimizeBox = false;
    this.Name = "clew";
    this.ShowInTaskbar = false;
    this.Text = "提示……";
    this.TopMost = true;
    this.Load += new System.EventHandler(this.clew_Load);
    this.ResumeLayout(false); }
    #endregion
    private string info;//设置提示窗体的内容;
    public string Info
    {
    set
    {
    info=value;
    }
    get
    {
    return info;
    }
    }
    private int heightMax, widthMax;//设置窗体显示的大小的属性
    public int HeightMax
    {
    set
    {
    heightMax = value; 
    }
    get
    {
    return heightMax;
    }
    } public int WidthMax
    {
    set
    {
    widthMax = value;
    }
    get
    {
    return widthMax;
    }
    }
    public void ScrollShow()
    {
    this.Width = widthMax;
    this.Height = 0;
    this.Show();
    this.timer1.Enabled = true;
    }
    public int StayTime = 5000;//窗体的停留时间
    //窗体的滚出与滚入方法
    private void ScrollUp()
    {
    if(Height < heightMax)
    {
    this.Height += 3;
    this.Location = new Point(this.Location.X, this.Location.Y - 3);
    }
    else
    {
    this.timer1.Enabled = false;
    this.timer2.Enabled = true;
    }
    } private void ScrollDown()
    {
    if(Height > 3)
    {
    this.Height -= 3;
    this.Location = new Point(this.Location.X, this.Location.Y + 3);
    }
    else
    {
    this.timer3.Enabled = false;
    this.Close();
    }
    }        private void clew_Load(object sender, System.EventArgs e)
    {
    string dNow;
    dNow=DateTime.Now.ToShortTimeString().ToString();
      
    this.label2.Text="现在时刻是:"+dNow;
    this.label1.Text=info;
    Screen[] screens = Screen.AllScreens;
    Screen screen = screens[0];//获取屏幕变量
    this.Location = new Point(screen.WorkingArea.Width - widthMax - 20, screen.WorkingArea.Height - 34);//WorkingArea为Windows桌面的工作区
    this.timer2.Interval = StayTime;  
    } private void timer1_Tick(object sender, System.EventArgs e)
    {
    ScrollUp(); } private void timer2_Tick(object sender, System.EventArgs e)
    {
    timer2.Enabled = false;
    timer3.Enabled = true; } private void timer3_Tick(object sender, System.EventArgs e)
    {
    ScrollDown(); }
    }
    }
      

  4.   

    new一个窗口
    不要标题栏
    设置一下颜色风格
    用Timer动一下就行了
      

  5.   

    codeproject上有很好用的,借鉴一下吧