Struct native_windows_gui::TrayNotification[][src]

pub struct TrayNotification {
    pub handle: ControlHandle,
}
Expand description

A control that handle system tray notification. A TrayNotification wraps a single icon in the Windows system tray.

An application can have many TrayNotification, but each window (aka parent) can only have a single traynotification. It is possible to create system tray only application with the MessageOnlyWindow control.

A system tray will receive events if callback is set to true in the builder (the default behaviour). The control will generate mouse events such as OnMouseMove when the user interact with the tray icon or the message popup. A system tray will also receive a OnContextMenu when the user right click the icon. It is highly recommended handle this message and display a popup menu

You can’t get information on the state of a tray notification (such as visibility) because Windows don’t want you to.

Builder parameters: * parent: Required. The tray notification parent container. * icon: Required. The icon to display in the system tray * tips: Display a simple tooltip when hovering the icon in the system tray * flags: A combination of the TrayNotificationFlags values. * visible: If the icon should be visible in the system tray * realtime: If the balloon notification cannot be displayed immediately, discard it. * info: Display a fancy tooltip when the system tray icon is hovered (replaces tip) * balloon_icon: The icon to display in the fancy tooltip
* info_title: The title of the fancy tooltip

Control events: * OnContextMenu: When the user right clicks on the system tray icon * MousePressLeftUp: When the user left click the system tray icon * OnTrayNotificationShow: When a TrayNotification info popup (not the tooltip) is shown * OnTrayNotificationHide: When a TrayNotification info popup (not the tooltip) is hidden * OnTrayNotificationTimeout: When a TrayNotification is closed due to a timeout * OnTrayNotificationUserClose: When a TrayNotification is closed due to a user click

Example

use native_windows_gui as nwg;

fn notice_user(tray: &nwg::TrayNotification, image: &nwg::Icon) {
    let flags = nwg::TrayNotificationFlags::USER_ICON | nwg::TrayNotificationFlags::LARGE_ICON;
    tray.show("Hello World", Some("Welcome to my application"), Some(flags), Some(image));
}
use native_windows_gui as nwg;
fn build_tray(tray: &mut nwg::TrayNotification, window: &nwg::Window, icon: &nwg::Icon) {
    nwg::TrayNotification::builder()
        .parent(window)
        .icon(Some(icon))
        .tip(Some("Hello"))
        .build(tray);
}

Winapi docs: https://docs.microsoft.com/en-us/windows/win32/shell/notification-area

Fields

handle: ControlHandle

Implementations

Set the visibility of the icon in the system tray

Set the tooltip for the tray notification. Note: tip will be truncated to 127 characters

Set the focus to the tray icon

Update the icon in the system tray

Shows a popup message on top of the system tray

Parameters:

  • text: The text in the popup
  • title: The title of the popup
  • flags: Flags that specify how the popup is shown. Default is NO_ICON | QUIET.
  • icon: Icon to display in the popup. Only used if USER_ICON is set in flags.

Note 1: text will be truncated to 255 characters Note 2: title will be truncated to 63 characters

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.