diff --git a/mkdocs-website/docs/en/changelog.md b/mkdocs-website/docs/en/changelog.md index 55106f401..c0913a9de 100644 --- a/mkdocs-website/docs/en/changelog.md +++ b/mkdocs-website/docs/en/changelog.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed service name determination by [windom](https://github.com/windom/) in [#3827](https://github.com/wailsapp/wails/pull/3827) - mkdocs serve now uses docker by [leaanthony](https://github.com/leaanthony) - Consolidated dev config into `config.yml` by [leaanthony](https://github.com/leaanthony) +- Systray dialog now defaults to the application icon if available (Windows) by [@leaanthony](https://github.com/leaanthony) ### Fixed - Fixed cross-platform cleanup for .syso files during Windows build by [ansxuman](https://github.com/ansxuman) in [#3924](https://github.com/wailsapp/wails/pull/3924) diff --git a/v3/pkg/application/systemtray_windows.go b/v3/pkg/application/systemtray_windows.go index bb8be8880..426823b7c 100644 --- a/v3/pkg/application/systemtray_windows.go +++ b/v3/pkg/application/systemtray_windows.go @@ -4,12 +4,11 @@ package application import ( "fmt" + "github.com/wailsapp/wails/v3/pkg/icons" "syscall" "time" "unsafe" - "github.com/wailsapp/wails/v3/pkg/icons" - "github.com/samber/lo" "github.com/wailsapp/wails/v3/pkg/events" @@ -202,15 +201,21 @@ func (s *windowsSystemTray) run() { panic(syscall.GetLastError()) } - if s.parent.icon != nil { - s.lightModeIcon = lo.Must(w32.CreateSmallHIconFromImage(s.parent.icon)) + // Get the application icon if available + defaultIcon := w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON) + if defaultIcon != 0 { + s.lightModeIcon = defaultIcon + s.darkModeIcon = defaultIcon } else { s.lightModeIcon = lo.Must(w32.CreateSmallHIconFromImage(icons.SystrayLight)) + s.darkModeIcon = lo.Must(w32.CreateSmallHIconFromImage(icons.SystrayDark)) + } + + if s.parent.icon != nil { + s.lightModeIcon = lo.Must(w32.CreateSmallHIconFromImage(s.parent.icon)) } if s.parent.darkModeIcon != nil { s.darkModeIcon = lo.Must(w32.CreateSmallHIconFromImage(s.parent.darkModeIcon)) - } else { - s.darkModeIcon = lo.Must(w32.CreateSmallHIconFromImage(icons.SystrayDark)) } s.uid = nid.UID diff --git a/v3/pkg/w32/constants.go b/v3/pkg/w32/constants.go index c32c9b531..3f762d85e 100644 --- a/v3/pkg/w32/constants.go +++ b/v3/pkg/w32/constants.go @@ -159,6 +159,30 @@ const ( IDI_INFORMATION = IDI_ASTERISK ) +const ( + RT_CURSOR = 1 // win32.MAKEINTRESOURCE(1) + RT_BITMAP = 2 + RT_ICON = 3 + RT_MENU = 4 + RT_DIALOG = 5 + RT_STRING = 6 + RT_FONTDIR = 7 + RT_FONT = 8 + RT_ACCELERATOR = 9 + RT_RCDATA = 10 + RT_MESSAGETABLE = 11 + RT_GROUP_CURSOR = 12 + RT_GROUP_ICON = 14 + RT_VERSION = 16 + RT_DLGINCLUDE = 17 + RT_PLUGPLAY = 19 + RT_VXD = 20 + RT_ANICURSOR = 21 + RT_ANIICON = 22 + RT_HTML = 23 + RT_MANIFEST = 24 +) + // Button style constants const ( BS_3STATE = 5