1), Framework1.1版本. 怎樣顯示一個帶關閉按鈕的托盤圖標提示?
I was able to find a simple answer. Instead of using:
TaskbarIcon.ShowBalloonTip(10000);
I could use the second form of this function:
TaskbarIcon.ShowBalloonTip(10000,"Title","Message",ToolTipIcon.None);
This actually adds a close box to the balloon tip!
=========================================================================
2), Framework2.0版本, 改進了NotifyIcon.
2.1), 怎樣在沒有Timeout的情況下關閉托盤圖標的氣泡提示?
設置NotifyIcon.Visible=false,氣泡提示會立刻關閉;
然後再設置NotifyIcon.Visible=true;即可;
2.2), 為什麼ShowBalloonTip函數設置的超時時間無效?
因為超時時間有區間限制: 10m-30m, 不在此范圍內的設置會自動向最近的區間值靠攏.
附錄:
NotifyIcon is .NETs version of the system tray icon, those little icons that appear next to the clock in the Windows Start bar. .NET 2.0 added the ability to display a pop-up balloon tip pointing at a tray icon. However, this capability doesnt always work as you would expect.
he NotifyIcon.ShowBalloonTip method has the following signature:
The NotifyIcons balloon tip will appear for a minimum of 10 seconds and maximum of 30 seconds, though this can vary by operating system. Timeout values that are too small or too large will be forced into this range.
If the user is not using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout, and the balloon tip could appear indefinitely. The logic is that users should not miss notifications when they are away from their computer.
Only one balloon tip can appear on the system tray at one time. If an application attempts to display a second balloon tip, the first balloon is closed immediately (regardless of the timeout setting) and the second balloon appears. However, if the first balloon was displayed by another application, it wont close until its timeout expires, at which point the second balloon will appear.
If an application exits without explicitly setting the NotifyIcon.Visibleproperty to false, the icon remains in the system tray (though it disappears when the user moves the mouse over the icon). And if a balloon tip was showing for that icon, the balloon will remain visible even after the application has exited.
To explicitly close a balloon at any time, simply set theNotifyIcon.Visible property to false, then immediately back to true.