You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92-28Lines changed: 92 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -14,24 +14,21 @@
14
14
WinToast
15
15
===================
16
16
17
-
WinToast is a lightly library written in C++ which brings a complete integration of the modern **toast notifications** of **Windows 8** &**Windows 10**.
17
+
WinToast is a lightly library written in C++ which brings a complete integration of the modern **toast notifications** of **Windows 8**, **Windows 10** and **Windows 11**.
18
18
19
19
Toast notifications allows your app to inform the users about relevant information and timely events that they should see and take action upon inside your app, such as a new instant message, a new friend request, breaking news, or a calendar event.
20
20
21
21
-[WinToast](#wintoast)
22
22
-[Toast Templates](#toast-templates)
23
23
-[Event Handler](#event-handler)
24
-
-[Expiration Time](#expiration-time)
25
-
-[Additional features available on Windows 10](#additional-features-available-on-windows-10)
24
+
-[Notification Content](#notification-content)
26
25
-[Error Handling](#error-handling)
27
26
-[Example of Usage](#example-of-usage)
28
27
-[Installation](#installation)
29
28
-[Toast configuration on Windows 10](#toast-configuration-on-windows-10)
30
29
-[Projects using WinToast](#projects-using-wintoast)
31
30
32
31
33
-
<divid='id1' />
34
-
35
32
## Toast Templates
36
33
37
34
WinToast integrates all standard templates available in the [ToastTemplateType enumeration](https://msdn.microsoft.com/en-us/library/windows/apps/br208660.aspx).
**Note:** The user can use the default system sound or specify a sound to play when a toast notification is displayed. Same behavior for the toast notification image, by default Windows try to use the app icon.*
59
56
60
-
<divid='id3' />
61
57
62
58
## Event Handler
63
59
@@ -82,9 +78,12 @@ class WinToastHandlerExample : public IWinToastHandler {
82
78
void toastFailed() const override;
83
79
};
84
80
```
85
-
<div id='id4' />
86
81
87
-
## Expiration Time
82
+
## Notification Content
83
+
84
+
The full documentation of the notification content [here](https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=appsdk).
85
+
86
+
### Expiration Time
88
87
89
88
Set the time after which a toast notification is no longer considered current or valid and should not be displayed. Windows attempts to raise toast notifications immediately after you call Show, so this property is rarely used.
90
89
@@ -94,34 +93,97 @@ Set the time after which a toast notification is no longer considered current or
94
93
**Note:** Default Windows behavior is to hide notification automatically after time set in Windows Ease of Access Settings.
95
94
If you need to preserve notification in Windows Action Center for longer period of time, you have to call `WinToastTemplate::setExpiration` method.
96
95
97
-
<div id='id5' />
96
+
### Hint Crop
97
+
98
+
Microsoft style guidelines recommend representing profile pictures with a circular image to provide a consistent representation of people across apps and the shell. Set the HintCrop property to Circle to render the image with a circular crop.
templ.setTextField(L"Matt sent you a friend request", WinToastTemplate::FirstLine);
103
+
templ.setTextField(L"Hey, wanna dress up as wizards and ride around on hoverboards?", WinToastTemplate::SecondLine);
104
+
templ.setImagePath(L"C:/example.png");
105
+
templ.setHintCrop(WinToastTemplate::Circle);
106
+
```
107
+
108
+

109
+
98
110
99
-
## Additional features available on Windows 10
111
+
### Hero Image
100
112
101
-
If your system supports the new modern features (Version > Windows 8.1) available in Windows 10, you can add some interesting fields as:
113
+
The hero image is a large image that appears at the top of a toast notification. The hero image is optional and can be used to provide additional context to the user.
102
114
103
-
- **Actions**: you can add your own actions, this fact allow you to interact with user in a different way:
115
+
**Note:** The hero image is not supported on Windows 8.1 and Windows Phone 8.1.
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
121
+
templ.setHeroImagePath(L"C:/example.png");
122
+
```
123
+
124
+

125
+
126
+
The hero image is specified by calling the `WinToastTemplate::setHeroImagePath` method. The image path can be a local file path or a URI.
127
+
128
+
129
+
### Inline Image
130
+
131
+
The second parameter of the method `WinToastTemplate::setHeroImagePath` is a boolean value that specifies whether the image should be inlined in the toast notification.
templ.setTextField(L"New product in stock", WinToastTemplate::FirstLine);
109
148
110
149
std::vector<std::wstring> actions;
111
-
actions.push_back(L"Yes");
112
-
actions.push_back(L"No");
113
-
for (auto const &action : actions)
150
+
actions.push_back(L"See more details");
151
+
actions.push_back(L"Remind me later");
152
+
// ...
153
+
154
+
for (autoconst &action : actions) {
114
155
templ.addAction(action);
156
+
}
115
157
WinToast::instance()->showToast(templ, handler)
116
158
```
117
159
118
-

119
-
-**Attribution text**: you can add/remove the attribution text, by default is empty. Use `WinToastTemplate::setAttributionText` to modify it.
120
-
-**Duration**: The amount of time the toast should display. This attribute can have one of the following values:
121
-
- *System*: default system configuration.
160
+

161
+
162
+
163
+
### Attribution text
164
+
165
+
New in Anniversary Update: If you need to reference the source of your content, you can use attribution text. This text is always displayed below any text elements, but above inline images. The text uses a slightly smaller size than standard text elements to help to distinguish from regular text elements.
***By default, WinToast checks if your systems support the features, ignoring the not supported ones.***
134
196
135
-
<divid='id2' />
136
-
137
197
## Error Handling
138
198
There are several reasons WinToast can fail that's why the library notifies caller about fail reason. Those are the code for each failure:
139
199
@@ -167,7 +227,6 @@ if (!launched) {
167
227
}
168
228
```
169
229
170
-
<div id='id6' />
171
230
172
231
## Example of Usage
173
232
@@ -218,7 +277,8 @@ if (!WinToast::instance()->showToast(templ, handler)) {
218
277
std::wcout << L"Error: Could not launch your toast notification!" << std::endl;
219
278
}
220
279
```
221
-
<div id='id7' />
280
+
281
+
Shao Voon Wong wrote an excellent article about the usage of WinToast. You can find it [here](https://www.codeproject.com/Articles/1151733/WinToast-Toast-Notification-Library-for-Windows-10).
222
282
223
283
## Installation
224
284
@@ -232,15 +292,19 @@ The system configuration helps you to define how long you want notifications to
232
292
233
293

234
294
235
-
<div id='id8' />
236
295
237
296
## Projects using WinToast
238
297
- [Git for Windows](https://github.com/git-for-windows/git): A fork of Git containing Windows-specific patches.
298
+
- [Firefox](https://hg.mozilla.org/mozilla-central/file/tip/third_party/WinToast/wintoastlib.cpp): A free and open source web browser.
239
299
- [QGIS](https://github.com/qgis/QGIS): QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
300
+
- [Synergy Core](https://github.com/symless/synergy-core): Share one mouse and keyboard between multiple computers
301
+
- [Siv3D](https://github.com/Siv3D/OpenSiv3D): A C++20 cross-platform library for creative coding
240
302
- [MEGAsync](https://github.com/meganz/MEGAsync): Easy automated syncing between your computers and your MEGA Cloud Drive
241
303
- [chatterino2](https://github.com/Chatterino/chatterino2): Chat client for twitch.tv
242
304
- [nheko](https://github.com/Nheko-Reborn/nheko): Desktop client for the Matrix protocol.
243
305
- [EDPathFinder](https://github.com/neotron/EDPathFinder): A program that creates an optimal route that passes through two or more systems in Elite.
306
+
- [IW6X-Client](https://github.com/XLabsProject/iw6x-client): IW6x is a free, open-source, community-driven project aiming to recreate the multiplayer experience of Call of Duty: Modern Warfare 3.
307
+
- [H1-Mod](https://github.com/h1-mod/h1-mod): A client for Call of Duty: Modern Warfare Remastered.
244
308
- [AntiExploit](https://github.com/Empier/Anti-Exploit): antiexploit utility for Windows.
245
309
- [Zroya](https://github.com/malja/zroya): Python extension for creating native Windows notifications..
246
310
- [PidginWinToastNotifications](https://github.com/ChristianGalla/PidginWinToastNotifications): Windows Toast Notification Plugin for Pidgin.
0 commit comments