libnick 2025.1.0
A cross-platform base for native Nickvision applications.
|
An icon for the Windows system tray. More...
#include <notifyicon.h>
Public Member Functions | |
NotifyIcon (HWND hwnd, const std::wstring &tooltip, const NotifyIconMenu &contextMenu={ }, bool hidden=false) | |
Constructs a NotifyIcon. | |
~NotifyIcon () | |
Destructs a NotifyIcon. | |
bool | hide () |
Hides the icon. | |
bool | show () |
Shows the icon. | |
const std::wstring & | getTooltip () const |
Gets the tooltip text of the icon. | |
bool | setTooltip (const std::wstring &tooltip) |
Sets the tooltip text of the icon. | |
const NotifyIconMenu & | getContextMenu () const |
Gets the context menu of the icon. | |
bool | setContextMenu (const NotifyIconMenu &menu) |
Sets the context menu of the icon. | |
bool | notify (const ShellNotificationSentEventArgs &e) |
Shows a notification from the icon. | |
Static Public Member Functions | |
static NotifyIcon * | getFromHWND (HWND hwnd) |
Gets a NotifyIcon from an HWND. | |
An icon for the Windows system tray.
This API is only available on Windows.
Nickvision::Notifications::NotifyIcon::NotifyIcon | ( | HWND | hwnd, |
const std::wstring & | tooltip, | ||
const NotifyIconMenu & | contextMenu = { }, | ||
bool | hidden = false ) |
Constructs a NotifyIcon.
hwnd | The HWND handle of the main application window |
tooltip | The tooltip text of the icon |
menu | The model for the context menu of the NotifyIcon |
hidden | Whether or not the NotifyIcon should be hidden by default |
std::runtime_error | Thrown if unable to create the NotifyIcon |
Nickvision::Notifications::NotifyIcon::~NotifyIcon | ( | ) |
Destructs a NotifyIcon.
const NotifyIconMenu & Nickvision::Notifications::NotifyIcon::getContextMenu | ( | ) | const |
Gets the context menu of the icon.
|
static |
Gets a NotifyIcon from an HWND.
hwnd | HWND |
const std::wstring & Nickvision::Notifications::NotifyIcon::getTooltip | ( | ) | const |
Gets the tooltip text of the icon.
bool Nickvision::Notifications::NotifyIcon::hide | ( | ) |
Hides the icon.
bool Nickvision::Notifications::NotifyIcon::notify | ( | const ShellNotificationSentEventArgs & | e | ) |
Shows a notification from the icon.
Supports the action "open" with action param being a path of a file or folder to open.
e | ShellNotificationSentEventArgs |
bool Nickvision::Notifications::NotifyIcon::setContextMenu | ( | const NotifyIconMenu & | menu | ) |
Sets the context menu of the icon.
menu | The model for the context menu |
bool Nickvision::Notifications::NotifyIcon::setTooltip | ( | const std::wstring & | tooltip | ) |
Sets the tooltip text of the icon.
tooltip | The toolip text |
bool Nickvision::Notifications::NotifyIcon::show | ( | ) |
Shows the icon.