Advanced: Shell Replacement sysTray, animated icons

Pleh

Active member
Joined
Sep 5, 2006
Messages
36
Programming Experience
3-5
Hi everyone, this is a pritty specific question and im pritty sure no one out there will be able to help me, but its worth a try :)

I am developing a replacement shell for windows xp.

So far i have window management and the system tray pritty much done, the problem i am having is that certain applications (MSN Messenger for example) have animated tray icons, usually when a tray icon is added the hIcon is a pointer to an icon in memory and it is the same each time a tray redraw is needed, this works fine for programs like skype and uTorrent and the icons are drawn fine in my system tray. The problem is that msn messenger does not pass a valid hIcon to the system tray, the pointer i get changes dramaticly every time the icon is added or modified. as far as i can tell this only happens for animated tray icons like NOD32 antivirus and MSN. Does anyone know what the intptr i am passed as a hIcon in these instances is actually representing?
 
Your right, this is a toughy and i'm not sure that i could give you a resolution. But here are my thoughts, i was under the impression that an animated systray icon is just several icons played over the top of one another. So could the reason be that you are getting a different hIcon pointer be that it is a different icon all together, displayed from an array of hIcons? Maybe a long shot.........
 
I thought that might be the case at first too, but if it were the hIcon should still point to a valid icon in memory, but it apparently doesnt.

What you are describing is correct, task managers tray icon that shows the cpu usage is actually 10 seperate icons and task manager sends a Modify message to the shell every time it needs to change icon, then windows displays the icon based on the updated hIcon passed in this message.

but for some reason msn messenger works differently, i think it may use some other kind of image format instead of an icon for the aminated parts like when you recieve an email. but that is just a guess, it could be something completely different.

Thanks for the ideas tho :) keep em comming :)
 
I'm not convinced of that. It wouldn't make sense for MS to use a different image format for the icon in the tray. I take it you are getting a hold of the NotifyIconData Structure that is passed to the tray?
 
Yeah, here is one of the data structures im using...

VB.NET:
<StructLayout(LayoutKind.Sequential)> _
PublicStructure NID
Public cbSize As UInt32
Public hwnd As IntPtr
Public uid As UInt32 
Public uFlags As UInt32 
Public uCallbackMessage As UInt32 
Public hIcon As IntPtr
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=128)> Public szTip() AsChar
Public dwState As UInt32 
Public dwStateMask As UInt32 
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=256)> Public szInfo() AsChar
Public uTimeOutOrVersion As UInt32 
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=64)> Public szInfoTitle() AsChar
Public dwInfoFlags As UInt32 
Public guidItem As IntPtr 
EndStructure
for most tray icons the hIcon passed here is valid and i can draw it without a problem, but when msn messenger passes this message the hIcon is different every time (even when the icon hasnt changed) and it is not a valid hIcon.
 
Last edited by a moderator:
Where did you get that Structure from. I think i should look more like this....

VB.NET:
<StructLayout(LayoutKind.Sequential)> _ 
Private Structure NOTIFYICONDATA
 Public cbSize As Int32
 Public hwnd As Int32
 Public uID As Int32
 Public uFlags As Int32
 Public uCallbackMessage As Int32
 Public hIcon As IntPtr
 <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64
)> _ 
 Public szTip As String
End Structure

EDIT: Changed the hIcon to an IntPtr
 
that structure is for windows NT, windows 2k and xp use some optional parameters, either way the hIcon is in the same place in both structures so it actually doesnt make a difference which one i use.
 
Yes i know, it wasn't so much the optional elements i was referring to, it was that types that you have declared in the structure. To run in compatibility for VB.Net you would need an Int32 not an UInt32 when marshalling the IntPtr back to the NotifyIconData Strucutre. However seeing as it works with other icons, this apparently, is not the problem.
I'll need to give this a try i think, i'll see if i can come up with something.
 
Mmmm... it seems this guy had the same problem, with Winzip and the infamous messenger icons...

http://www.codeproject.com/tools/ShellTrayInfo.asp

As for my delphi, well it's pretty useless. I just wish i could be of more help. it strikes me as very peculier. Perhaps you were right from the start and they have used a different image format, but i just can't figure out why they would want to do that.
 
I found the same article a few mins ago too and have left him a message to see if he ever figured it out.

It is definatly a strange one. I guess i will have to wait for his reply which will probably be a no.

Thanks for putting in the time to help me :) i thought it was a bit of a long shot that someone would know the difinitive answer :)
 
Thanks for the links, i just checked them all out, there is some interesting stuff in the second one but none of them have helped me solve my problem, that Bos shell thing in the second link said it had a system tray in it but it doesnt, its just a space for the clock :(

im not going to give up yet tho, im gonna keep looking :)
 
Back
Top