Something that has always annoyed me is the weird 16 color limitation of trayicons in windows. I believe this is solved in XP (&ME?) but as I'm not using (and don't plan to use) XP but 2K this doesn't solve the problem for me.

I was wondering if there's a workaround for this limitation. It would be nice if I could 'custom draw' the system tray so I can draw the icon myself. Or using an blank (transparent) icon, and hooking the toolbar window the tray consists of to draw a better image over it. Hooking would probably require a DLL and I prefer not to use one, but I think it's inevitable.

Anyone knows of a way to do this?

Thomas
Posted on 2002-05-23 13:21:33 by Thomas
Custom draw is a nice idea. But hard to solve, because you need to get a "free" place in the tray (by putting a blank icon there?) and need to know the exact position where to draw.

But here is one way to set it to 256 colors:
http://www.virtualplastic.org/html/icn_sys.html#5

Don't think you like that solution :)
Posted on 2002-05-23 13:31:38 by bazik
Well I don't think the users of my program would like it if it started modifying explorer.exe :grin:.
Another solution I thought of is to replace the imagelist of the toolbar with a new imagelist that uses more colors (I think the 16 color limit is due to the imagelist type, though I'm not sure).
It's not a very elegant solution but it might work. However this also requires access to the explorer process as the image list handles are only valid in the process they were created in...
By default, my program will use the normal way to display a trayicon but it's quite ugly. If I can create a workaround, it will be an option in the program ('turn this on if you want to try to use nicer trayicons. use at your own risk :)')

Thomas
Posted on 2002-05-23 13:40:28 by Thomas
Heh, I remember on my old Apple (Only 16 colors for graphics at the time) some game company came up with a neat solution to this exact problem. Its not the *greatest* solution out there, but it works and doesnt require any overhead.

If you pick your 16 colors right you can create the illusion of blending by staggering the colors.

Yellow(X)
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX

Blue(O)
OOOOO
OOOOO
OOOOO
OOOOO
OOOOO

Green
XOXOX
OXOXO
XOXOX
OXOXO
XOXOX

Just an idea. It worked really well on the Apple its resultion was terrible. I bet it looks much better on todays monitors...
Posted on 2002-05-23 14:52:14 by Graebel
Graebel: I know that method but it still looks terrible. I managed to tweak my system with a similair trick as described on the website (don't ask me how, I can't tell on this board). It's just that the image list is set to ILC_COLOR (which defaults to ILC_COLOR4 on most systems). I have no idea why microsoft didn't use ILC_COLOR32 or something.

Thomas
Posted on 2002-05-23 14:56:47 by Thomas
Yeah I was wondering what it would look like. Guess I know now hehe :tongue:

Hmm, well a much harder way would be to enumerate the system tray and add your own little window to it and draw a 32 bit icon on it. I remember seeing some programs that would add custom windows there, but I did not mess with them much.
Posted on 2002-05-23 15:17:58 by Graebel
Well, there is an VB example somewhere on planetsourcecode.com, wich shows how to display the complete "ToolbarWindow32" (how it's called under XP) in the VB Form and remove it from the Taskbar. This would be one way to add your own Icon quite easy. Gonna search for that example...
Posted on 2002-05-23 15:23:33 by bazik