如何在通知区域中不添加图标的情况下使用 Shell_NotifyIcon
MSDN 关于通知和通知区域的文档非常清楚为了显示通知,通知区域中有一个图标的要求:
要显示通知,您必须 通知中有一个图标 区域。在某些情况下,例如 Microsoft Communicator 或电池 级别,该图标已经是 展示。然而,在许多其他情况下, 您将添加一个图标到 通知区域只要是 需要显示通知。
由于我不希望向通知区域添加任何图标,因此我正在考虑“重用”最有可能出现在典型桌面上的现有图标。一个好的候选者可能是系统时钟。
我的问题是:
- 我如何找到/枚举 NOTIFYICONDATA 结构 系统时钟(又名“日期和时间 属性”恢复时)?
- 有没有更好的方法 实现这一点(不添加 一个图标)?
MSDN's documentation about Notifications and the Notification Area is pretty clear in the requirement for having an icon in the notification area in order to display a notification:
To display a notification, you must
have an icon in the notification
area. In certain cases, such as
Microsoft Communicator or battery
level, that icon will already be
present. In many other cases, however,
you will add an icon to the
notification area only as long as is
needed to show the notification.
Since I do not wish to add any icon to the notification area, I was thinking of perhaps "reusing" an existing one that is most likely to be there on a typical desktop. A good candidate may be the system clock.
My questions are:
- How do I find/enumerate the
NOTIFYICONDATA structure for the
system clock (AKA "Date and Time
Properties" when restored)? - Is there a better way of
accomplishing this (without adding
an icon)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Shell_NotifyIcon 在底层使用 IUserNotification。我尝试了一下并用它制作了一个实用程序。我听说有一位视障系统管理员使用它来使他的脚本屏幕阅读器兼容。它是命令行,没有消息循环。
它具有自我意识,这意味着发送给它的通知将排队(您可以控制它)。为了实现这一点,我提供了一个 IQueryContinue 实现。该项目是用 C++ 编写的,并且是开源的,请自行帮助。
这是它的核心内容:
Shell_NotifyIcon uses IUserNotification under the hood. I played around with it and made a utility out of it. I heard of a visually impaired sysadmin who uses it to make his scripts screen reader compatible. It is command line, it does not have a message loop.
It is self aware, meaning that notifications sent to it will be queued (you have control over it). For that to work, I provided a IQueryContinue implementation. The project is in C++ and is open source, help yourself.
Here is the guts of it :