2009-01-20 54 views
9

我創建了一個在任務欄中運行的應用程序。當用戶點擊應用程序時,它彈出等。我想要的是類似的功能,當我的一個朋友登錄在MSN中。顯然這是知道作爲吐司彈出? 我基本上想要從任務欄中的應用程序每20分鐘吐出一次風格。我的應用程序的烤麪包風格彈出式菜單

我現有的應用程序是基於WinForms的C#編寫的與.NET 3.5

乾杯

回答

21

這是非常簡單的。您只需要將窗口設置在屏幕外區域並對其位置設置動畫,直到其完全可見。下面是一個示例代碼:

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); 
    } 
} 
+5

Ť他沒有考慮幾個因素: *任務欄可以附加到屏幕的任何邊緣; *用戶可以在右側有一個輔助監視器(導致您的彈出窗口在任務欄附近無處彈出) 我知道這是一條舊線程,但我想提及其他任何人,因爲我是。 – Geoff 2011-06-27 13:40:10

4

有在Win32的通知氣球支持(我不是一個.NET程序員),一些有用的特性old new thing explains

還有一個系統範圍的信號燈,您應該鎖定以防止一次出現任何應用程序的多個彈出窗口。

在msdn-the toast semaphorbroader context of usability上有幾頁關於吐司信號。我也遇到了一些example code使用C#中的氣球api,但不能擔保。

-1

您正在將屏幕移出屏幕,然後將其擡起。它永遠不會進入桌面視圖。 X軸是左右的,Y軸是上下的。添加到X軸會使其更加正確,並且添加到Y軸會使其進一步向下。