Page 1 of 1

AddSysTrayIcon - ImageID always invalid

Posted: Fri Mar 24, 2023 5:10 am
by Hi-Toro
Hi all,

I haven't been here for a while, just not doing a lot of programming these days, but tonight I've run into this problem under PureBasic 5.70 LTS (Windows - x64): trying to load an icon (.ico) and use it with AddSysTrayIcon always fails for me, with "[ERROR] AddSysTrayIcon(): The specified 'ImageID' is not valid."

Am I doing something stupid here? I was trying to use CatchImage on an included binary, then LoadImage, and finally CreateImage -- all show a valid IsImage result, but fail with this message.

As far as I can tell this minimal example (please run in Debug mode) is doing the same as the SysTray.pb docs example...

Code: Select all


; RUN IN DEBUG MODE!

icon = CreateImage (#PB_Any, 32, 32)

; Non-zero!

Debug IsImage (icon)

window = OpenWindow (#PB_Any, 0, 0, 100, 100, "")

systray = AddSysTrayIcon (#PB_Any, WindowID (window), icon)

; [ERROR] AddSysTrayIcon(): The specified 'ImageID' is not valid.

End

I'm sure it's me, but what am I missing here?

Re: AddSysTrayIcon - ImageID always invalid

Posted: Fri Mar 24, 2023 6:13 am
by BarryG
[Deleted]

Re: AddSysTrayIcon - ImageID always invalid

Posted: Fri Mar 24, 2023 7:11 am
by PeDe
Hello Hi-Toro,

you forgot 'ImageID(...)' at 'AddSysTrayIcon(...)'.

Code: Select all

icon = CreateImage (#PB_Any, 32, 32)
Debug IsImage (icon)
window = OpenWindow (#PB_Any, 0, 0, 100, 100, "")
systray = AddSysTrayIcon (#PB_Any, WindowID (window), ImageID(icon))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: AddSysTrayIcon - ImageID always invalid

Posted: Fri Mar 24, 2023 11:05 am
by Hi-Toro
Aaaarrgghhhh! Thanks, PeDe! I knew it would be me -- I thought I was meant to pass the image handle, but I get it now, thank you.