请问如何在c#中制作像msn的那种在屏幕又下角弹出的窗体啊?
想做一个特效,不知道如何解决

解决方案 »

  1.   

    用API函数AnimateWindow.
    [DllImport("user32", CharSet = CharSet.Auto)]
     public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
    具体用法自己找下MSDN吧。
      

  2.   

    如是Web可以用脚本的定时控制一个层的显示消失等来达到该效果
    如是Win则可以在一个From里用一个时间轴来进行这些控制。
      

  3.   

    private void button1_Click(object sender, System.EventArgs e)
    {
        Form2 form = new Form2();
        form.HeightMax = 50;//窗体滚动的高度
        form.WidthMax = 80;//窗体滚动的宽度
        form.ScrollShow();
        form.Opacity=0;}
    ///////////////////////////////////////From窗体
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace testmsn
    {
    /// <summary>
    /// Form2 的摘要说明。
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.Timer timer2;
    private System.Windows.Forms.Timer timer3;
    private System.ComponentModel.IContainer components; public int StayTime = 5000; private int heightMax, widthMax; public int HeightMax
    {
    set
    {
    heightMax = value;
    }
    get
    {
    return heightMax;
    }
    } public int WidthMax
    {
    set
    {
    widthMax = value;
    }
    get
    {
    return widthMax;
    }
    }
    public Form2()
    {
    //
    // 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.timer2 = new System.Windows.Forms.Timer(this.components);
    this.timer3 = new System.Windows.Forms.Timer(this.components);
    this.SuspendLayout();
    // 
    // label1
    // 
    this.label1.ForeColor = System.Drawing.Color.Brown;
    this.label1.Location = new System.Drawing.Point(16, 16);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(104, 16);
    this.label1.TabIndex = 0;
    this.label1.Text = "你好,你上线了!";
    // 
    // timer1
    // 
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // timer2
    // 
    this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
    // 
    // timer3
    // 
    this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
    // 
    // Form2
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.BackColor = System.Drawing.Color.Green;
    this.ClientSize = new System.Drawing.Size(144, 48);
    this.Controls.Add(this.label1);
    this.ForeColor = System.Drawing.SystemColors.ActiveBorder;
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.Name = "Form2";
    this.ShowInTaskbar = false;
    this.Text = "Form2";
    this.TopMost = true;
    this.Load += new System.EventHandler(this.Form2_Load);
    this.ResumeLayout(false); }
    #endregion
    public void ScrollShow()
    {
    this.Width = widthMax;
    this.Height = 0;
    this.Show();
    this.timer1.Enabled = true;
    }
    private void ScrollUp()
    {
    if(Height < heightMax)
    {
    this.Opacity = this.Opacity+0.1;
    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.Opacity = this.Opacity-0.1;
    this.Height -= 3;
    this.Location = new Point(this.Location.X, this.Location.Y + 3);
    }
    else
    {
    this.timer3.Enabled = false;
    this.Close();
    }
    } 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();

    } private void Form2_Load(object sender, System.EventArgs e)
    {
    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; } }
    }