问题描述
我正在尝试将一些 Windows 10 功能集成到我现有的 Windows 桌面应用程序中.我在集成 Toast 通知方面有些困难.使用 toast 通知示例 (https://code.msdn.microsoft.com/windowsdesktop/sending-toast-notifications-71e230a2/) 我能够实现代码来发送和隐藏通知.当用户点击活动"通知时,我的应用程序中的事件处理程序也会被调用.
I'm trying to integrate some Windows 10 features into my existing Windows Desktop application. I am a little stuck integrating the Toast Notifications. Using the toast notification example (https://code.msdn.microsoft.com/windowsdesktop/sending-toast-notifications-71e230a2/) I was able to implement code to send and hide notifications. It also works, that when the user clicks on an 'active' notification an event handler in my application is invoked.
但是,一旦通知在操作中心"中存档",用户点击我的通知时就不会发生任何事情.在这种情况下,我该如何对点击做出反应?
However, as soon as the notification is 'archived' in the 'Action Center', nothing happens when the user clicks on my notification. How can I react to clicks in such situations?
感谢您的帮助,
卢卡斯
推荐答案
我开发了 WinToast,一个用 C++ 编写的库可以轻松集成 Windows Toast 通知.我用它在不同的项目中集成了 Toast 通知,特别是与 Qt 框架.
I have developed WinToast, a library written in C++ to integrate Windows Toast Notification easily. I have used it to integrate Toast notifications in different projects, specially with Qt Framework.
原生 Toast Notification 需要 Com Fundamentals 仅在现代版本的 Windows 中可用(最低支持的客户端:Windows 8).
The native Toast Notification needs some functions of the Com Fundamentals which are availables only in moderns version of Windows (minimum supported client: Windows 8).
这就是库动态加载所有必需库的原因.使用 WinToast 使您的应用程序与旧版本的 Windows 兼容.附带的示例说明了如何在存储库中使用它.
That's why the library loads all the required libraries dynamically. Make your application compatible with older versions of Windows using WinToast. There is an attached example explaining how to use it in the repository.
要显示祝酒词,只需创建模板和自定义处理程序并启动它:
To show a toast, just create the template and your custom handler and launch it:
WinToastHandlerExample* handler = new WinToastHandlerExample;
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageWithTwoLines);
templ.setImagePath(L"C:/example.png");
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
if (!WinToast::instance()->showToast(templ, handler)) {
std::wcout << L"Could not launch your toast notification!";
}
这篇关于Windows 10 Toast 通知桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!