[英]How to add toast style popup to my application?
我創建了一個在任務欄中運行的應用程序。 當用戶點擊應用程序時,它會彈出等等。當我的一個朋友登錄時,我想要的功能與MSN中的功能類似。顯然這是一個知道的吐司彈出窗口? 我基本上希望從任務欄中的應用程序每隔20分鍾彈出一些東西。
我現有的應用程序是基於C#和.net 3.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);
}
}
在Win32中支持通知氣球(我不是.net程序員),有一些有用的屬性,如舊的新東西所解釋的那樣 。
還有一個系統范圍的信號量,你應該鎖定它以防止一次出現的任何應用程序彈出多個彈出窗口。
在msdn上的吐司信號上有幾頁 - 吐司信號和更廣泛的可用性 。 我還看到了一些示例代碼 ,在查看時使用C#的氣球api,但無法保證它。
還有Windows 8風格Toast通知:
http://code.msdn.microsoft.com/windowsapps/Toast-notifications-sample-52eeba29
您正在將窗體移出屏幕右側,然后將其抬起。 它實際上永遠不會進入桌面視圖。 X軸為左右,Y軸為上下。 添加到X軸使其更加正確,並且添加到Y軸使其進一步向下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.