[][src]Struct native_windows_gui::TrayNotification

pub struct TrayNotification {
    pub handle: ControlHandle,
}

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

impl TrayNotification[src]

pub fn builder<'a>() -> TrayNotificationBuilder<'a>[src]

pub fn set_visibility(&self, v: bool)[src]

Set the visibility of the icon in the system tray

pub fn set_tip<'a>(&self, tip: &'a str)[src]

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

pub fn set_focus(&self)[src]

Set the focus to the tray icon

pub fn set_icon(&self, icon: &Icon)[src]

Update the icon in the system tray

pub fn show<'a>(
    &self,
    text: &'a str,
    title: Option<&'a str>,
    flags: Option<TrayNotificationFlags>,
    icon: Option<&'a Icon>
)
[src]

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

impl Default for TrayNotification[src]

impl Drop for TrayNotification[src]

impl Eq for TrayNotification[src]

impl<'_> From<&'_ TrayNotification> for ControlHandle[src]

impl PartialEq<ControlHandle> for TrayNotification[src]

impl PartialEq<TrayNotification> for TrayNotification[src]

impl PartialEq<TrayNotification> for ControlHandle[src]

impl StructuralEq for TrayNotification[src]

impl StructuralPartialEq for TrayNotification[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.