atom
May 23, 2009, 11:28pm
1
i wanted to get the tray icon back after explorer crach, to do that some stuff need to be done
from codeproject.com
Every time explorer starts up (including after a crash), it broadcasts a registered message to every top level window. This is named “TaskbarCreated”.
To restore your icon, you just have to intercept that message and call Shell_NotifyIcon when it comes.
Early in your code (I have it as a global const variable) call the code:
const UINT WM_TASKBARCREATED = RegisterWindowMessage(_T(“TaskbarCreated”)) ;
Explorer now sends WM_TASKBARCREATED messages each time it starts.
Detect this message in your Window Procedure. When it occurs, call Shell_NotifyIcon with NIM_ADD.
No need for polling. Smile
I classify this as part of the necessary boilerplate code that gets a tray icon working. That’s not the only boilerplate code; what about the menu problem mentioned in kb135788[^]?
For those that don’t want to add the boilerplate code, either switch to .NET’s NotifyIcon class (which handles all the idiosyncrasies for you), or stop using tray icons.
(I got this info from MSDN[^]) Red faced. (I’m not the type of person that orders everyone to RTFM, despite this hypocritical oxymoron of a paragraph).
do you think you could add this message to the tray icon class.
jules
May 24, 2009, 10:15am
2
That’s a bit of a PITA, it means keeping a list of all the taskbar comps somewhere so it can tell them all when the taskbar changes. But yes, I suppose I’ll add this sometime.
atom
May 24, 2009, 4:16pm
3
maybe some sort of Desktop() class listener class that we can register our components with, and will recevie notifications from Desktop() when this (or some other bad things) happen.