在c# winform的程序中怎么做像MSN那样的消息窗体呀???多谢

解决方案 »

  1.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace Test___
    {
    /// <summary>
    /// Popup 的摘要说明。
    /// </summary>
    public class Popup : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Timer timer1;
    private System.ComponentModel.IContainer components; public Popup()
    {
    //
    // 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.label1 = new System.Windows.Forms.Label();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.SuspendLayout();
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(16, 28);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(164, 60);
    this.label1.TabIndex = 0;
    this.label1.Text = "文本内容";
    // 
    // timer1
    // 
    this.timer1.Interval = 50;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // Popup
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(200, 116);
    this.Controls.Add(this.label1);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.Location = new System.Drawing.Point(824, 768);
    this.Name = "Popup";
    this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    this.Text = "Popup";
    this.TopMost = true;
    this.Load += new System.EventHandler(this.Popup_Load);
    this.ResumeLayout(false); }
    #endregion private bool blCountWait = false;
    int nStart = 0;
    private void timer1_Tick(object sender, System.EventArgs e)
    {
    if (!blCountWait)
    {
    if(this.Height +this.Top >Screen.PrimaryScreen.Bounds.Height)
    {
    this.Top-=10;
    }
    else
    {
    blCountWait = true;
    nStart = System.Environment.TickCount;
    }
    }
    else
    {
    if (System.Environment.TickCount - nStart>5000)
    {
    this.Close();
    }
    }
    } private void Popup_Load(object sender, System.EventArgs e)
    {
    timer1.Enabled = true;
    }
    }
    }
      

  2.   

    上面的是弹出式窗体模拟代码。退出可以使用改变透明度退出。效果更好。调用代码如下:
    private void button7_Click(object sender, System.EventArgs e)
    {
    System.Threading.WaitCallback wcbPop = 
    new System.Threading.WaitCallback(PopForm);
    System.Threading.ThreadPool.QueueUserWorkItem(wcbPop,new Popup());
    }

    private void PopForm(object frm)
    {
    Application.Run(frm as Popup);
    }
      

  3.   

    http://www.codeproject.com/aspnet/asppopup.asp