windows C/C++ 中的弹出通知程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5638886/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:37:17  来源:igfitidea点击:

Popup notifiers in C/C++

c++cwindowsnotifications

提问by WebWeasel

I've been working on a project that will need a notifier in the system tray (sorry, "System Notification Area"). It will be a simple app that just generates popup notifications when it receives a message via a Zeromq socket.

我一直在从事一个项目,该项目需要系统托盘中的通知程序(抱歉,“系统通知区域”)。这将是一个简单的应用程序,当它通过 Zeromq 套接字接收到消息时只生成弹出通知。

I am not having any luck finding anything other than .NET resources and examples. Does anyone have a sample in C/C++?

除了 .NET 资源和示例之外,我没有任何运气找到任何东西。有人在 C/C++ 中有示例吗?

回答by Nick Meyer

I would start with this section of MSDN: Notifications and the Notification Area.

我将从 MSDN 的这一部分开始:通知和通知区域

Then I'd check the NotificationIcon Samplein the Windows SDK.

然后我会检查Windows SDK 中的NotificationIcon Sample

回答by Boaz Yaniv

What framework are you using? There should probably be several implementations for MFC, but there might different implementation for WTL and other frameworks. If you want to use the Windows API with no object orientation - well, you won't need any wrapper library then, but you can look at these libraries for example.

你用的是什么框架?MFC 应该有几种实现,但 WTL 和其他框架可能有不同的实现。如果您想使用没有面向对象的 Windows API - 那么,您将不需要任何包装库,但您可以查看这些库,例如。

Here's one that has MFC and non-MFC version from CodeProject: http://www.codeproject.com/KB/shell/systemtray.aspx

这是来自 CodeProject 的 MFC 和非 MFC 版本:http: //www.codeproject.com/KB/shell/systemtray.aspx

What you want here is probably ShowBalloon() function, which shows a balloon notification, but I'm pretty sure you must create a tray icon for that (can't have a notification balloon without having a tray icon).

你想要的可能是 ShowBalloon() 函数,它显示一个气球通知,但我很确定你必须为此创建一个托盘图标(没有托盘图标就不能有通知气球)。