systray

package
v0.0.0-...-ca67efc Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: GPL-2.0, GPL-3.0, LGPL-3.0, + 1 more Imports: 4 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	WM_LBUTTONUP     = 0x0202
	WM_LBUTTONDBLCLK = 0x0203
	WM_RBUTTONUP     = 0x0205
	WM_USER          = 0x0400
	WM_TRAYICON      = WM_USER + 69

	WS_EX_APPWINDOW     = 0x00040000
	WS_OVERLAPPEDWINDOW = 0x00000000 | 0x00C00000 | 0x00080000 | 0x00040000 | 0x00020000 | 0x00010000
	CW_USEDEFAULT       = 0x80000000

	NIM_ADD        = 0x00000000
	NIM_MODIFY     = 0x00000001
	NIM_DELETE     = 0x00000002
	NIM_SETVERSION = 0x00000004

	NIF_MESSAGE = 0x00000001
	NIF_ICON    = 0x00000002
	NIF_TIP     = 0x00000004
	NIF_STATE   = 0x00000008
	NIF_INFO    = 0x00000010

	NIS_HIDDEN = 0x00000001

	NIIF_NONE               = 0x00000000
	NIIF_INFO               = 0x00000001
	NIIF_WARNING            = 0x00000002
	NIIF_ERROR              = 0x00000003
	NIIF_USER               = 0x00000004
	NIIF_NOSOUND            = 0x00000010
	NIIF_LARGE_ICON         = 0x00000020
	NIIF_RESPECT_QUIET_TIME = 0x00000080
	NIIF_ICON_MASK          = 0x0000000F

	IMAGE_BITMAP    = 0
	IMAGE_ICON      = 1
	LR_LOADFROMFILE = 0x00000010
	LR_DEFAULTSIZE  = 0x00000040

	IDC_ARROW     = 32512
	COLOR_WINDOW  = 5
	COLOR_BTNFACE = 15

	GWLP_USERDATA       = -21
	WS_CLIPSIBLINGS     = 0x04000000
	WS_EX_CONTROLPARENT = 0x00010000

	HWND_MESSAGE       = ^HWND(2)
	NOTIFYICON_VERSION = 4

	IDI_APPLICATION = 32512
	WM_APP          = 32768
	WM_COMMAND      = 273

	MenuItemMsgID       = WM_APP + 1024
	NotifyIconMessageId = WM_APP + iota

	MF_STRING       = 0x00000000
	MF_ENABLED      = 0x00000000
	MF_GRAYED       = 0x00000001
	MF_DISABLED     = 0x00000002
	MF_SEPARATOR    = 0x00000800
	MF_CHECKED      = 0x00000008
	MF_MENUBARBREAK = 0x00000020

	TPM_LEFTALIGN = 0x0000
	WM_NULL       = 0
)

Variables

View Source
var (
	GetModuleHandle  = kernel32.MustFindProc("GetModuleHandleW")
	GetConsoleWindow = kernel32.MustFindProc("GetConsoleWindow")
	GetLastError     = kernel32.MustFindProc("GetLastError")

	Shell_NotifyIcon = shell32.MustFindProc("Shell_NotifyIconW")

	GetMessage       = user32.MustFindProc("GetMessageW")
	IsDialogMessage  = user32.MustFindProc("IsDialogMessageW")
	TranslateMessage = user32.MustFindProc("TranslateMessage")
	DispatchMessage  = user32.MustFindProc("DispatchMessageW")

	ShowWindow       = user32.MustFindProc("ShowWindow")
	UpdateWindow     = user32.MustFindProc("UpdateWindow")
	DefWindowProc    = user32.MustFindProc("DefWindowProcW")
	RegisterClassEx  = user32.MustFindProc("RegisterClassExW")
	GetDesktopWindow = user32.MustFindProc("GetDesktopWindow")
	CreateWindowEx   = user32.MustFindProc("CreateWindowExW")

	CreatePopupMenu = user32.MustFindProc("CreatePopupMenu")

	LoadImage  = user32.MustFindProc("LoadImageW")
	LoadIcon   = user32.MustFindProc("LoadIconW")
	LoadCursor = user32.MustFindProc("LoadCursorW")
)

Functions

func MakeIntResource

func MakeIntResource(id uint16) *uint16

func NewIconFromFile

func NewIconFromFile(filePath string) (uintptr, error)

Types

type HANDLE

type HANDLE uintptr

type HBRUSH

type HBRUSH HGDIOBJ

type HCURSOR

type HCURSOR HANDLE

type HGDIOBJ

type HGDIOBJ HANDLE

type HICON

type HICON HANDLE

type HINSTANCE

type HINSTANCE HANDLE

func RegisterWindow

func RegisterWindow(name string, proc WindowProc) (HINSTANCE, error)

type HMENU

type HMENU HANDLE

type HWND

type HWND HANDLE

type MSG

type MSG struct {
	HWnd    HWND
	Message uint32
	WParam  uintptr
	LParam  uintptr
	Time    uint32
	Pt      POINT
}
type MenuItem struct {
	Label string

	Disabled  bool
	Checked   bool
	BarBreak  bool
	Separator bool

	OnClick func()
}

type NOTIFYICONDATA

type NOTIFYICONDATA struct {
	CbSize           uint32
	HWnd             HWND
	UID              uint32
	UFlags           uint32
	UCallbackMessage uint32
	HIcon            HICON
	SzTip            [128]uint16
	DwState          uint32
	DwStateMask      uint32
	SzInfo           [256]uint16
	UVersion         uint32
	SzInfoTitle      [64]uint16
	DwInfoFlags      uint32
	GuidItem         windows.GUID
	HBalloonIcon     HICON
}

type POINT

type POINT struct {
	X, Y int32
}

type Systray

type Systray struct {
	Menu []*MenuItem
	// contains filtered or unexported fields
}

func New

func New() (*Systray, error)

func (*Systray) AppendMenu

func (p *Systray) AppendMenu(label string, onclick func())

AppendMenu add menu item.

func (*Systray) AppendSeparator

func (p *Systray) AppendSeparator()

AppendSeparator to the menu.

func (*Systray) HWND

func (p *Systray) HWND() HWND

func (*Systray) OnClick

func (p *Systray) OnClick(fn func())

func (*Systray) OnRightClick

func (p *Systray) OnRightClick(fn func())

func (*Systray) Run

func (p *Systray) Run() error

func (*Systray) SetIcon

func (p *Systray) SetIcon(hicon HICON) error

func (*Systray) SetTooltip

func (p *Systray) SetTooltip(tooltip string) error

func (*Systray) SetVisible

func (p *Systray) SetVisible(visible bool) error

func (*Systray) Show

func (p *Systray) Show(iconResID uint16, hint string) error

Show shows custom tray icon.

func (*Systray) ShowCustom

func (p *Systray) ShowCustom(file string, hint string) error

ShowCustom shows custom tray icon.

func (*Systray) ShowMessage

func (p *Systray) ShowMessage(title, msg string, bigIcon bool) error

func (*Systray) Stop

func (p *Systray) Stop() error

func (*Systray) WinProc

func (p *Systray) WinProc(hwnd HWND, msg uint32, wparam, lparam uintptr) uintptr

type WNDCLASSEX

type WNDCLASSEX struct {
	CbSize        uint32
	Style         uint32
	LpfnWndProc   uintptr
	CbClsExtra    int32
	CbWndExtra    int32
	HInstance     HINSTANCE
	HIcon         HICON
	HCursor       HCURSOR
	HbrBackground HBRUSH
	LpszMenuName  *uint16
	LpszClassName *uint16
	HIconSm       HICON
}

type WindowProc

type WindowProc func(hwnd HWND, msg uint32, wparam, lparam uintptr) uintptr

Jump to

Keyboard shortcuts

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