winforms 停止任务栏闪烁
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stop the taskbar flashing
提问by lomaxx
I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow stop the flashing?
我知道我可以以编程方式使特定窗口的任务栏项目在发生变化时开始闪烁,但是有什么方法可以阻止它在一段时间后以编程方式闪烁,或者至少有一个我可以提供的键盘快捷键我的用户以某种方式停止闪烁?
回答by imaginaryboy
The FlashWindowExfunction which controls the flashing takes a FLASHWINFOstruct which has a uCount field to control how many times it flashes. Also, a possible value for the dwFlags field is FLASHW_STOP to cause the flashing to stop.
控制闪烁的FlashWindowEx函数采用一个FLASHWINFO结构,它有一个 uCount 字段来控制它闪烁的次数。此外,dwFlags 字段的一个可能值是 FLASHW_STOP 以导致闪烁停止。
EDIT: Forgot was a C# tagged question ... so P/Invoke goodness found here.
编辑:忘记是一个 C# 标记的问题......所以P/Invoke goodness found here。
回答by imaginaryboy
@thomas -- Amazingly Microsoft's own Windows Vista User Experience Guidelinesagree with you ...
@thomas——令人惊讶的是,微软自己的Windows Vista 用户体验指南同意你的看法......
While having a background window flash its taskbar button is better than having it automatically come to the top and steal input focus, flashing taskbar buttons are still very intrusive. It is hard for users to concentrate when a taskbar button is flashing, so you should assume that users will immediately stop what they are doing to make the flashing stop. Consequently, reserve taskbar flashing only for situations where immediate attention is required.
虽然让背景窗口闪烁其任务栏按钮比让它自动到达顶部并窃取输入焦点更好,但闪烁的任务栏按钮仍然非常具有侵入性。当任务栏按钮闪烁时,用户很难集中注意力,因此您应该假设用户会立即停止正在执行的操作以使闪烁停止。因此,仅在需要立即注意的情况下保留任务栏闪烁。
Of course who knows who actually follows those guidelines ... or who even reads them. :)
当然,谁知道谁真正遵循了这些指导方针……或者谁甚至阅读了这些指导方针。:)
回答by Marcus Erickson
Instead of flashing the tasbar you can consider using the NotifyIcon. This will let you put something on the system tray (something else many consider evil because of the proliferation of apps that do this). Then you can popup a ballon tip with any change that actually describes the change itself.
您可以考虑使用 NotifyIcon,而不是闪烁 tasbar。这将让您在系统托盘上放置一些东西(由于执行此操作的应用程序的激增,许多人认为其他东西是邪恶的)。然后,您可以弹出一个气球提示,其中包含实际描述更改本身的任何更改。
To use: (1) Drag the NotifyIcon onto your form or create in your app NotifyIcon notify = new NotifyIcon(); (2) Set the icon property to the required image (3) Control whether it is visible on the system tray using the Visible property (4) Call ShowBalloonText to show popup text (limited to 64 characters)
要使用: (1) 将 NotifyIcon 拖到您的表单上或在您的应用程序中创建 NotifyIcon notify = new NotifyIcon(); (2)设置icon属性为需要的图片 (3)使用Visible属性控制在系统托盘上是否可见 (4)调用ShowBalloonText显示弹出文本(限制为64个字符)
Either way, you shoudl add an option to the program that allows the end user to turn this feature on/off based on their feelings about it all. I personally like the notify icon because the ballon text can say something like "Server went down"
无论哪种方式,您都应该向程序添加一个选项,允许最终用户根据他们的感受打开/关闭此功能。我个人喜欢通知图标,因为气球文本可以说“服务器宕机”之类的东西

