mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 14:49:27 +08:00
[windows] Use application icon as default systray icon if available.
This commit is contained in:
parent
b37cdf5ba9
commit
f2040797d7
@ -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)
|
- 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)
|
- mkdocs serve now uses docker by [leaanthony](https://github.com/leaanthony)
|
||||||
- Consolidated dev config into `config.yml` 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
|
||||||
- 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)
|
- 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)
|
||||||
|
@ -4,12 +4,11 @@ package application
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/wailsapp/wails/v3/pkg/icons"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v3/pkg/icons"
|
|
||||||
|
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v3/pkg/events"
|
"github.com/wailsapp/wails/v3/pkg/events"
|
||||||
@ -202,15 +201,21 @@ func (s *windowsSystemTray) run() {
|
|||||||
panic(syscall.GetLastError())
|
panic(syscall.GetLastError())
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.parent.icon != nil {
|
// Get the application icon if available
|
||||||
s.lightModeIcon = lo.Must(w32.CreateSmallHIconFromImage(s.parent.icon))
|
defaultIcon := w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON)
|
||||||
|
if defaultIcon != 0 {
|
||||||
|
s.lightModeIcon = defaultIcon
|
||||||
|
s.darkModeIcon = defaultIcon
|
||||||
} else {
|
} else {
|
||||||
s.lightModeIcon = lo.Must(w32.CreateSmallHIconFromImage(icons.SystrayLight))
|
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 {
|
if s.parent.darkModeIcon != nil {
|
||||||
s.darkModeIcon = lo.Must(w32.CreateSmallHIconFromImage(s.parent.darkModeIcon))
|
s.darkModeIcon = lo.Must(w32.CreateSmallHIconFromImage(s.parent.darkModeIcon))
|
||||||
} else {
|
|
||||||
s.darkModeIcon = lo.Must(w32.CreateSmallHIconFromImage(icons.SystrayDark))
|
|
||||||
}
|
}
|
||||||
s.uid = nid.UID
|
s.uid = nid.UID
|
||||||
|
|
||||||
|
@ -159,6 +159,30 @@ const (
|
|||||||
IDI_INFORMATION = IDI_ASTERISK
|
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
|
// Button style constants
|
||||||
const (
|
const (
|
||||||
BS_3STATE = 5
|
BS_3STATE = 5
|
||||||
|
Loading…
Reference in New Issue
Block a user