Skip to content

Commit 41201c5

Browse files
committed
Updating the documentation to show the new use cases and features
1 parent d3fb4b0 commit 41201c5

File tree

9 files changed

+308
-125
lines changed

9 files changed

+308
-125
lines changed

README.md

Lines changed: 92 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,21 @@
1414
WinToast
1515
===================
1616

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**.
1818

1919
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.
2020

2121
- [WinToast](#wintoast)
2222
- [Toast Templates](#toast-templates)
2323
- [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)
2625
- [Error Handling](#error-handling)
2726
- [Example of Usage](#example-of-usage)
2827
- [Installation](#installation)
2928
- [Toast configuration on Windows 10](#toast-configuration-on-windows-10)
3029
- [Projects using WinToast](#projects-using-wintoast)
3130

3231

33-
<div id='id1' />
34-
3532
## Toast Templates
3633

3734
WinToast integrates all standard templates available in the [ToastTemplateType enumeration](https://msdn.microsoft.com/en-us/library/windows/apps/br208660.aspx).
@@ -57,7 +54,6 @@ templ.setImagePath(L"C:/example.png");
5754
```
5855
**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.*
5956

60-
<div id='id3' />
6157

6258
## Event Handler
6359

@@ -82,9 +78,12 @@ class WinToastHandlerExample : public IWinToastHandler {
8278
void toastFailed() const override;
8379
};
8480
```
85-
<div id='id4' />
8681
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
8887
8988
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.
9089
@@ -94,34 +93,97 @@ Set the time after which a toast notification is no longer considered current or
9493
**Note:** Default Windows behavior is to hide notification automatically after time set in Windows Ease of Access Settings.
9594
If you need to preserve notification in Windows Action Center for longer period of time, you have to call `WinToastTemplate::setExpiration` method.
9695
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.
99+
100+
```cpp
101+
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
102+
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+
!["Toast with hero image"](assets/images/hint-crop.png)
109+
98110

99-
## Additional features available on Windows 10
111+
### Hero Image
100112

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.
102114

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.
104116

105117
```cpp
106-
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::Text02);
107-
templ.setTextField(L"Do you think this feature is cool?", WinToastTemplate::FirstLine);
108-
templ.setTextField(L"Ofc,it is!", WinToastTemplate::SecondLine);
118+
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
119+
templ.setTextField(L"Mary Anne", WinToastTemplate::FirstLine);
120+
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
121+
templ.setHeroImagePath(L"C:/example.png");
122+
```
123+
124+
!["Toast with hero image"](assets/images/hero-image.png)
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.
132+
133+
```cpp
134+
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01);
135+
templ.setTextField(L"Feature image of the day", WinToastTemplate::FirstLine);
136+
templ.setHeroImagePath(L"C:/example.png", true);
137+
```
138+
139+
!["Toast with inlined hero image"](assets/images/inline-image.png)
140+
141+
### Actions
142+
143+
You can add your own actions, this fact allow you to interact with user in a different way:
144+
145+
```cpp
146+
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01);
147+
templ.setTextField(L"New product in stock", WinToastTemplate::FirstLine);
109148

110149
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 (auto const &action : actions) {
114155
templ.addAction(action);
156+
}
115157
WinToast::instance()->showToast(templ, handler)
116158
```
117159
118-
!["Toast with some actions"](https://lh3.googleusercontent.com/uJE_H0aBisOZ-9GynEWgA7Hha8tHEI-i0aHrFuOFDBsPSD-IJ-qEN0Y7XY4VI5hp_5MQ9xjWbFcm)
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+
!["Toast with some actions"](assets/images/image-actions.png)
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.
166+
167+
```cpp
168+
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::Text02);
169+
templ.setTextField(L"Mary Anne", WinToastTemplate::FirstLine);
170+
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
171+
templ.setHeroImagePath(L"C:/example.png");
172+
templ.setAttributionText(L"Via SMS");
173+
```
174+
175+
!["Toast with some actions"](assets/images/attribution-text.png)
176+
177+
### Duration
178+
179+
The amount of time the toast should display. This attribute can have one of the following values:
180+
- *System*: default system configuration.
122181
- *Short*: default system short time configuration.
123182
- *Long*: default system long time configuration.
124-
- **Audio Properties**: you can modify the different behaviors of the sound:
183+
184+
### Audio Properties
185+
186+
You can modify the different behaviors of the sound:
125187
- *Default*: plays the audio file just one time.
126188
- *Silent*: turn off the sound.
127189
- *Loop*: plays the given sound in a loop during the toast existence.
@@ -132,8 +194,6 @@ WinToast::instance()->showToast(templ, handler)
132194
133195
***By default, WinToast checks if your systems support the features, ignoring the not supported ones.***
134196

135-
<div id='id2' />
136-
137197
## Error Handling
138198
There are several reasons WinToast can fail that's why the library notifies caller about fail reason. Those are the code for each failure:
139199

@@ -167,7 +227,6 @@ if (!launched) {
167227
}
168228
```
169229
170-
<div id='id6' />
171230
172231
## Example of Usage
173232
@@ -218,7 +277,8 @@ if (!WinToast::instance()->showToast(templ, handler)) {
218277
std::wcout << L"Error: Could not launch your toast notification!" << std::endl;
219278
}
220279
```
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).
222282
223283
## Installation
224284
@@ -232,15 +292,19 @@ The system configuration helps you to define how long you want notifications to
232292
233293
![Ease of Access configuration](https://camo.githubusercontent.com/56c8edd1a7a4a43be07ba211d9d828478fdbad39/68747470733a2f2f7777772e686f77746f6765656b2e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f30332f656173655f6f665f6163636573732e706e67)
234294
235-
<div id='id8' />
236295
237296
## Projects using WinToast
238297
- [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.
239299
- [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
240302
- [MEGAsync](https://github.com/meganz/MEGAsync): Easy automated syncing between your computers and your MEGA Cloud Drive
241303
- [chatterino2](https://github.com/Chatterino/chatterino2): Chat client for twitch.tv
242304
- [nheko](https://github.com/Nheko-Reborn/nheko): Desktop client for the Matrix protocol.
243305
- [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.
244308
- [AntiExploit](https://github.com/Empier/Anti-Exploit): antiexploit utility for Windows.
245309
- [Zroya](https://github.com/malja/zroya): Python extension for creating native Windows notifications..
246310
- [PidginWinToastNotifications](https://github.com/ChristianGalla/PidginWinToastNotifications): Windows Toast Notification Plugin for Pidgin.

assets/images/attribution-text.png

220 KB
Loading

assets/images/hero-image.png

207 KB
Loading

assets/images/hint-crop.png

80.3 KB
Loading

assets/images/image-actions.png

72.6 KB
Loading

assets/images/inline-image.png

205 KB
Loading

0 commit comments

Comments
 (0)