C# 如何将toast样式的弹出窗口添加到我的应用程序中?
我已经创建了一个在任务栏中运行的应用程序。当用户点击应用程序时,它会弹出,等等。我想要的是类似于MSN的功能,当我的一个朋友登录时。很明显,这被称为祝酒弹出窗口? 我基本上希望每隔20分钟在任务栏中的应用程序中弹出一些东西C# 如何将toast样式的弹出窗口添加到我的应用程序中?,c#,winforms,C#,Winforms,我已经创建了一个在任务栏中运行的应用程序。当用户点击应用程序时,它会弹出,等等。我想要的是类似于MSN的功能,当我的一个朋友登录时。很明显,这被称为祝酒弹出窗口? 我基本上希望每隔20分钟在任务栏中的应用程序中弹出一些东西 我现有的应用程序是用C#和.NET3.5编写的基于winforms的,这非常简单。你们只需要在屏幕外区域设置窗口,并设置它的位置动画,直到它完全可见。下面是一个示例代码: public partial class Form1 : Form { private Time
我现有的应用程序是用C#和.NET3.5编写的基于winforms的,这非常简单。你们只需要在屏幕外区域设置窗口,并设置它的位置动画,直到它完全可见。下面是一个示例代码:
public partial class Form1 : Form
{
private Timer timer;
private int startPosX;
private int startPosY;
public Form1()
{
InitializeComponent();
// We want our window to be the top most
TopMost = true;
// Pop doesn't need to be shown in task bar
ShowInTaskbar = false;
// Create and run timer for animation
timer = new Timer();
timer.Interval = 50;
timer.Tick += timer_Tick;
}
protected override void OnLoad(EventArgs e)
{
// Move window out of screen
startPosX = Screen.PrimaryScreen.WorkingArea.Width - Width;
startPosY = Screen.PrimaryScreen.WorkingArea.Height;
SetDesktopLocation(startPosX, startPosY);
base.OnLoad(e);
// Begin animation
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
//Lift window by 5 pixels
startPosY -= 5;
//If window is fully visible stop the timer
if (startPosY < Screen.PrimaryScreen.WorkingArea.Height - Height)
timer.Stop();
else
SetDesktopLocation(startPosX, startPosY);
}
}
公共部分类表单1:表单
{
私人定时器;
私人int startPosX;
私人int startPosY;
公共表格1()
{
初始化组件();
//我们希望我们的窗户是最好的
最顶端=真;
//Pop不需要显示在任务栏中
ShowInTaskbar=false;
//创建并运行动画计时器
定时器=新定时器();
时间间隔=50;
timer.Tick+=定时器_Tick;
}
受保护的覆盖无效加载(事件参数e)
{
//将窗口移出屏幕
startPosX=Screen.PrimaryScreen.WorkingArea.Width-Width;
startPosY=Screen.PrimaryScreen.WorkingArea.Height;
SetDesktopLocation(startPosX、startPosY);
基础荷载(e);
//开始动画
timer.Start();
}
无效计时器勾号(对象发送方,事件参数e)
{
//将窗口提升5像素
startPosY-=5;
//如果窗口完全可见,请停止计时器
if(启动OSY
Win32中支持通知气球(我不是.net程序员),并提供了一些有用的属性
还有一个系统范围的信号量,您应该锁定它,以防止任何应用程序同时出现多个弹出窗口
msdn上的toast信号量有几页,在。我在查看时也遇到一些人使用C#中的balloon api,但无法对此进行担保。您正在将表单从屏幕移到右侧,然后将其升高。它永远不会真正进入桌面视图。X轴左右,Y轴上下。添加到X轴会使其更向右移动,添加到Y轴会使其更向下移动。可定制且外观更好的通知 检查此链接