AddSysTrayIcon - ImageID always invalid

Everything else that doesn't fall into one of the other PB categories.
Hi-Toro
Enthusiast
Enthusiast
Posts: 265
Joined: Sat Apr 26, 2003 3:23 pm

AddSysTrayIcon - ImageID always invalid

Post 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?
James Boyd
http://www.hi-toro.com/
Death to the Pixies!
BarryG
Addict
Addict
Posts: 3268
Joined: Thu Apr 18, 2019 8:17 am

Re: AddSysTrayIcon - ImageID always invalid

Post by BarryG »

[Deleted]
Last edited by BarryG on Fri Mar 24, 2023 9:21 am, edited 1 time in total.
PeDe
Enthusiast
Enthusiast
Posts: 119
Joined: Sun Nov 26, 2017 3:13 pm
Location: Vienna
Contact:

Re: AddSysTrayIcon - ImageID always invalid

Post 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
Hi-Toro
Enthusiast
Enthusiast
Posts: 265
Joined: Sat Apr 26, 2003 3:23 pm

Re: AddSysTrayIcon - ImageID always invalid

Post 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.
James Boyd
http://www.hi-toro.com/
Death to the Pixies!
Post Reply