Application.Idle 仅在我将鼠标悬停在托盘图标上后触发

发布于 2024-11-06 12:28:48 字数 107 浏览 0 评论 0原文

我想在程序的 Application.Idle 事件中显示 BalloonTip,但由于某种原因,Application.Idle 事件仅在我将鼠标悬停在 NotifyIcon 上后才会触发。什么给?

I want to show a BalloonTip in the Application.Idle event of my program, but for some reason the Application.Idle event only fires after I mouse over the NotifyIcon. What gives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住我的手 2024-11-13 12:28:48

您确定 Application.Idle 没有被解雇吗?简单的方法是每当代码进入事件时登录到文件并查看是否发生这种情况。

另请理解,此事件可能不适合您的需求 - 当消息泵变空时(通常没有键盘/鼠标输入),它会发生 - 因此您可能会过于频繁地收到此事件(请参阅 这个SO线程了解更多)。在这种情况下,我怀疑窗口可能会抑制气球尖端,因为它显示得太频繁。

因此,您可以编码以仅在最后 2-3 秒内未显示提示时显示提示。您可能需要查看空闲检测的不同实现来满足您的要求 - 请查看:

  1. http://ellisweb.net/2008/02/detecting-application-idle-state-in-windows-forms/
  2. http://blog.opennetcf.com/ctacke/2009/05/19/DetectingApplicationIdle.aspx
  3. < a href="http://www.codeproject.com/KB/miscctrl/Application_Idle.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/miscctrl/Application_Idle.aspx

Are you sure that Application.Idle is not getting fired? Simple way would be to log into the file whenever code enters the event and see if this happening.

Also understand that this event may not be suitable for your needs - it happens when message pump becomes empty (typically no keyboard/mouse input) - so as such you would probably receive this event too frequently (see this SO thread to understand more). In this case, I suspect that windows is suppressing the balloon tip perhaps because it is being shown too frequently.

As such, you can code to show the tip only if it has not been shown say in last 2-3 seconds. You may want to look at different implementations of Idle detection to suit your requirements - have a look at:

  1. http://ellisweb.net/2008/02/detecting-application-idle-state-in-windows-forms/
  2. http://blog.opennetcf.com/ctacke/2009/05/19/DetectingApplicationIdle.aspx
  3. http://www.codeproject.com/KB/miscctrl/Application_Idle.aspx
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文