aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKali Kaneko2018-10-18 11:42:25 +0200
committerKali Kaneko2018-10-18 11:45:39 +0200
commit5fb0feca3c0677e9fa31e579ff69631f49a379a2 (patch)
treeed17fcd244333d0640448a7577e5ed33bf7dbb76
parent99cf6a5c182815c5fec856856f897d9c6f1018ab (diff)
downloadsystray-5fb0feca3c0677e9fa31e579ff69631f49a379a2.tar.bz2
make addOrUpdateMenuItem insert item if it was deleted
Currently, a menu item that was previously hidden (ie, deleted) will not return -1, and so when we're in the Show() code execution path we will never insert it in the previous position: attempts at Show() are failing because it tries to update a non-existing item. - Resolves: #67
-rw-r--r--systray_windows.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/systray_windows.go b/systray_windows.go
index 7a9d7a1..3624214 100644
--- a/systray_windows.go
+++ b/systray_windows.go
@@ -463,8 +463,10 @@ func (t *winTray) addOrUpdateMenuItem(menuId int32, title string, disabled, chec
// The return value is the identifier of the specified menu item.
// If the menu item identifier is NULL or if the specified item opens a submenu, the return value is -1.
+ // If the given menu identifier is not found (becase we deleted the menu item when hiding it),
+ // the call will return the next integer that is available as an existing menu item.
res, _, err := pGetMenuItemID.Call(uintptr(t.menu), uintptr(menuId))
- if int32(res) == -1 {
+ if int32(res) == -1 || int32(res) != menuId {
res, _, err = pInsertMenuItem.Call(
uintptr(t.menu),
uintptr(menuId),