notifyicon

package
v0.0.0-...-3929c03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CallbackMessage = appmsg.NOTIFY_ICON_CALLBACK

CallbackMessage is the message sent to the window when mouse or keyboard interaction occurs in the bounding rectangle of the icon. Process this message manually or use Spec.OnEvent.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event win32.WORD

Event is the interaction event occurs in the bounding rectangle of the icon.

const (
	NIN_SELECT           Event = (win32.WM_USER + 0) // Notify icon is selected by mouse or keyboard.
	NINF_KEY             Event = 0x1
	NIN_KEYSELECT        Event = (NIN_SELECT | NINF_KEY) // Notify icon is selected by or keyboard.
	NIN_BALLOONSHOW      Event = (win32.WM_USER + 2)
	NIN_BALLOONHIDE      Event = (win32.WM_USER + 3)
	NIN_BALLOONTIMEOUT   Event = (win32.WM_USER + 4)
	NIN_BALLOONUSERCLICK Event = (win32.WM_USER + 5)
	NIN_POPUPOPEN        Event = (win32.WM_USER + 6) // Tooltip is needed.
	NIN_POPUPCLOSE       Event = (win32.WM_USER + 7)
	MIN_CONTEXTMENU      Event = win32.WM_CONTEXTMENU // Action to trigger the shortcut menu(i.e. right click).
)

func ParseCallback

func ParseCallback(wParam win32.WPARAM, lParam win32.LPARAM) (id win32.WORD, event Event, eventX win32.SHORT, eventY win32.SHORT)

ParseCallback parses the parameters of CallbackMessage. id is the identifier of notify icon. event is the interaction event occurred. eventX/Y is the event coordinates.

type Modifier

type Modifier struct {
	// contains filtered or unexported fields
}

Modifier is used to modify notify icon. A typical usage is a

modifier.SetXXX(...).SetXXX(...).Apply()

See [StartModify].

func (*Modifier) Apply

func (m *Modifier) Apply() error

Apply applies the change.

func (*Modifier) SetIcon

func (m *Modifier) SetIcon(icon win32.HICON) *Modifier

func (*Modifier) SetNotify

func (m *Modifier) SetNotify(spec *NotifySpec) *Modifier

SetNotify sets the ballon notification.

func (*Modifier) SetTip

func (m *Modifier) SetTip(tip string) *Modifier

SetTip sets the tooltip string. if tip is "", NIN_POPUPOPEN event is sent to allow showing application-drawn tooltip.

type NotifyIcon

type NotifyIcon struct {
	// contains filtered or unexported fields
}

NotifyIcon is an icon in taskbar's status area.

func New

func New(w *window.Window, id win32.WORD, spec *Spec) (*NotifyIcon, error)

New adds an icon to taskbar's status area. An NotifyIcon is identified by a window and an ID.

func (*NotifyIcon) Delete

func (icon *NotifyIcon) Delete() error

Delete removes the icon.

func (*NotifyIcon) ID

func (icon *NotifyIcon) ID() win32.UINT

func (*NotifyIcon) SetFocus

func (icon *NotifyIcon) SetFocus() error

SetFocus returns focus to the taskbar notification area. Notification area icons should use this method when they have completed their UI operation. For example, if the icon displays a shortcut menu, but the user presses ESC to cancel it, this method to return focus to the notification area.

func (*NotifyIcon) StartModify

func (icon *NotifyIcon) StartModify() *Modifier

StartModify returns a Modifier which can be used to modify the notify icon identified by w and id.

type NotifySpec

type NotifySpec struct {
	// Icon of notification. BI_xxx or a real HICON
	// If Title is empty string, the icon is not shown.
	Icon win32.HICON
	// Title of notification.
	Title string
	// Message of notification.
	Message string
	// Do not play the notifications sound.
	NoSound bool
	// Use (SM_CXICON x SM_CYICON) instead of (SM_CXSMICON x SM_CYSMICON) icon dimension.
	LargeIcon bool
	// If the notification cannot be displayed immediately, discard it.
	RealTime bool
	// Do not display the balloon notification if the current user is in "quiet time"
	RespectQuietTime bool
}

type Spec

type Spec struct {
	// Icon in system tray.
	Icon win32.HICON
	// Tool tip string. if Tip is "", [NIN_POPUPOPEN] event is sent to allow showing application-drawn tooltip.
	Tip string
	// The ballon notification.
	Notify *NotifySpec
	// Optional callback to receive events.
	OnEvent func(id win32.WORD, event Event, eventX win32.SHORT, eventY win32.SHORT)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL