关于C#托盘图标控件NotifyIcon的气泡提示-程序开发-红黑联盟

来源:百度文库 编辑:神马文学网 时间:2024/04/28 18:18:54
关于C#托盘图标控件NotifyIcon的气泡提示
文章录入:王子    责任编辑:dingkai1983  208
【字体:小大】
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 .NET's 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 doesn't always work as you would expect.
he NotifyIcon.ShowBalloonTip method has the following signature:
ShowBalloonTip(Int32) – Displays a balloon tip in the system tray for the specified time period (in milliseconds). ShowBalloonTip(Int32, String, String, ToolTipIcon) – Displays a balloon tip with the specified title, text, and icon in the system tray for the specified time period.
Issue #1: Timeout Limits
The NotifyIcon's 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.
Issue #2: Requires User Activity
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.
Issue #3: One Balloon at a Time
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 won't close until its timeout expires, at which point the second balloon will appear.
Issue #4: Balloon Never Closes
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.
Tip: To Close Balloons
To explicitly close a balloon at any time, simply set theNotifyIcon.Visible property to false, then immediately back to true.