rodrigocfd / windigo

Windows API and GUI in idiomatic Go.

Home Page:https://pkg.go.dev/github.com/rodrigocfd/windigo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System tray example?

lonnietc opened this issue · comments

Hello,

I am researching GUI frameworks for Golang and came across yours.

Is there any popup system tray example?

Thanks

Windigo is a very thin layer over the Win32 API, so any C or C++ system tray example should work.

This is the simplest example I can think of:

nid := win.NOTIFYICONDATA{}
nid.SetCbSize()

nid.Hwnd = hWnd // the owner HWND goes here...
nid.UID = 20_000 // any ID number
nid.UFlags = co.NIF_ICON | co.NIF_MESSAGE | co.NIF_TIP
nid.HIcon = hIcon // the icon to be shown
nid.SetSzTip("You hovered the tray icon")

win.ShellNotifyIcon(co.NIM_ADD, &nid)

And when closing your application, remove the system tray icon:

win.ShellNotifyIcon(co.NIM_DELETE, &nid)