libnick 2025.1.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Notifications::NotifyIcon Class Reference

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 NotifyIconMenugetContextMenu () 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 NotifyIcongetFromHWND (HWND hwnd)
 Gets a NotifyIcon from an HWND.
 

Detailed Description

An icon for the Windows system tray.

This API is only available on Windows.

Constructor & Destructor Documentation

◆ NotifyIcon()

Nickvision::Notifications::NotifyIcon::NotifyIcon ( HWND hwnd,
const std::wstring & tooltip,
const NotifyIconMenu & contextMenu = { },
bool hidden = false )

Constructs a NotifyIcon.

Parameters
hwndThe HWND handle of the main application window
tooltipThe tooltip text of the icon
menuThe model for the context menu of the NotifyIcon
hiddenWhether or not the NotifyIcon should be hidden by default
Exceptions
std::runtime_errorThrown if unable to create the NotifyIcon

◆ ~NotifyIcon()

Nickvision::Notifications::NotifyIcon::~NotifyIcon ( )

Destructs a NotifyIcon.

Member Function Documentation

◆ getContextMenu()

const NotifyIconMenu & Nickvision::Notifications::NotifyIcon::getContextMenu ( ) const

Gets the context menu of the icon.

Returns
The model for the context menu

◆ getFromHWND()

static NotifyIcon * Nickvision::Notifications::NotifyIcon::getFromHWND ( HWND hwnd)
static

Gets a NotifyIcon from an HWND.

Parameters
hwndHWND
Returns
The NotifyIcon associated with the HWND if found, else nullptr

◆ getTooltip()

const std::wstring & Nickvision::Notifications::NotifyIcon::getTooltip ( ) const

Gets the tooltip text of the icon.

Returns
The tooltip text

◆ hide()

bool Nickvision::Notifications::NotifyIcon::hide ( )

Hides the icon.

Returns
True if icon was hidden, else false

◆ notify()

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.

Parameters
eShellNotificationSentEventArgs
Returns
True if notification was shown from the icon

◆ setContextMenu()

bool Nickvision::Notifications::NotifyIcon::setContextMenu ( const NotifyIconMenu & menu)

Sets the context menu of the icon.

Parameters
menuThe model for the context menu
Returns
True if the context menu was updated, else false

◆ setTooltip()

bool Nickvision::Notifications::NotifyIcon::setTooltip ( const std::wstring & tooltip)

Sets the tooltip text of the icon.

Parameters
tooltipThe toolip text
Returns
True if the tooltip was updated, else false

◆ show()

bool Nickvision::Notifications::NotifyIcon::show ( )

Shows the icon.

Returns
True if icon was shown, else false

The documentation for this class was generated from the following file: