效果:
Form2 制作不规则窗体:

Form2:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MSNMessageForm
{
public partial class Form2 : Form
{
private int heightMax, widthMax;
public int StayTime = 5000;//窗体停留时间(默认为5秒)
public int HeightMax
{
set
{
heightMax = value;
}
get
{
return heightMax;
}
}
public int WidthMax
{
set
{
widthMax = value;
}
get
{
return widthMax;
}
}
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Screen[] screens = Screen.AllScreens;
Screen screen = screens[0];//获取屏幕变量
this.Location = new Point(screen.WorkingArea.Width - widthMax - this.Width, screen.WorkingArea.Height - this.Height);
//WorkingArea为Windows桌面的工作区
this.timer2.Interval = StayTime;
}
public void ScrollShow()
{
this.Height = 0;
this.Show();
this.timer1.Enabled = true;
}
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 timer3_Tick(object sender, EventArgs e)
{
ScrollDown();
}
private void timer2_Tick(object sender, EventArgs e)
{
timer2.Enabled = false;
timer3.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
ScrollUp();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Form1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MSNMessageForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnTest_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.HeightMax = 120;//窗体滚动的高度
form.WidthMax = 148;//窗体滚动的宽度
form.ScrollShow();
}
}
}
浙公网安备 33010602011771号