MSN有信息或邮件时,会缓慢出现一个信息窗口. 其实不难,E8.Net平台中 开发的项目中有做个小信使功能. 提示方式类似MSN有新信息来一样.
首先: 有个窗体 form1.aspx 实现小图标 出现在 右下脚.
关键点: 窗体Opacity 属性 设置为 0% 隐藏
放置一个控件 NotifyIcon ,实现右下角图标功能
菜单代码:
private void Form1_Load(object sender, EventArgs e)

{
MenuItem menuItem1 = new MenuItem("未读邮件");
MenuItem menuItem2 = new MenuItem("待办事项");
MenuItem menuItemP2 = new MenuItem("-");
MenuItem menuItem6 = new MenuItem("切换用户");
MenuItem menuItemP1 = new MenuItem("-");
MenuItem menuItem4 = new MenuItem("退出程序");
//分别为4个菜单项添加Click事件响应函数
menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
menuItem6.Click += new EventHandler(menuItem6_Click);
//设置NotifyIcon对象的ContextMenu属性为生面的弹出菜单对象


niTools.ContextMenu = new ContextMenu(new MenuItem[]
{ menuItem1, menuItem2, menuItemP2, menuItem6, menuItemP1, menuItem4 });

InitBrowserInterface();


}
提示窗口实现:
当有新邮件时:
FrmShowEmail frm = new FrmShowEmail();
frm.Opener = this;
frm.EmailCount = iEmailCnt;
frm.EmailSubject = strEmailSubject;
frm.EmailFrom = strEmailFrom;
frm.EmailDate = dtLastEmail.ToString("yyyy-MM-dd hh:mm");
frm.HeightMax = 180;//窗体滚动的高度
frm.WidthMax = 268;//窗体滚动的宽度
frm.ScrollShow();
实现的慢慢弹出的关键代码在 frmShowEmail.aspx中
放置了三个时间控件 Timer1 Timer2 Timer3 分别设置 Interval = 60 100 60
关键代码:
private void FrmShowEmail_Load(object sender, 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;

}

public void ScrollShow()

{

Application.DoEvents();
this.Width = widthMax;
this.Height = 0;
this.Show();

this.timer2.Enabled = false;
this.timer3.Enabled = false;
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 > 40)

{
this.Height -= 3;
this.Location = new Point(this.Location.X, this.Location.Y + 3);
}
else

{
this.timer3.Enabled = false;
this.Close();
this.Dispose();
}
}

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();
}
首先: 有个窗体 form1.aspx 实现小图标 出现在 右下脚.
关键点: 窗体Opacity 属性 设置为 0% 隐藏
放置一个控件 NotifyIcon ,实现右下角图标功能
菜单代码:





























提示窗口实现:
当有新邮件时:










实现的慢慢弹出的关键代码在 frmShowEmail.aspx中
放置了三个时间控件 Timer1 Timer2 Timer3 分别设置 Interval = 60 100 60
关键代码:


























































































