Reputation: 43
I am trying to learn how to show Toast notifications from my program which is native c++ console application registered as a windows service.
I learnt that Toasts are part of the windows runtime UI components; So does this mean I have to develop a GUI component for my product in order to be able to send Toasts?
Upvotes: 2
Views: 6362
Reputation: 4050
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.
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).
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"imagepath");
templ.setTextField(L"firstline", 0);
templ.setTextField(L"secondline", 1);
if (!WinToast::instance()->showToast(templ, handler)) {
std::wcout << L"Could not launch your toast notification!";
}
Upvotes: 3
Reputation: 498
Yes it might be possible check this link Here Certain WinRT classes can be used from desktop apps, including portions of the Windows.UI namespace. The toast notification APIs are one such example - they can be used by both Windows Store apps and desktop apps
Upvotes: 0