A customer found that sometimes their program starts up too soon,
and when it tried to create its taskbar notification icon,
the call to
Shell_
fails.
The customer wanted to know whether there was a signal they
could listen for to tell them that the taskbar has finished
booting completely and is ready to accept notification icons.
They noticed that the system puts up an hourglass cursor,
and they wondered if perhaps there was a way to monitor the system
cursor and wait for it to change to something other than an hourglass.
NotifyIcon
You can listen for the
TaskbarCreated
message,
which the taskbar sends
when the taskbar has been created.
Upon receipt of that message, you can try to create
your icon again.
The customer asked,
"Okay, that's great.
But sometimes our program runs after the taskbar has
been created.
How can I tell whether the taskbar has been created,
so I know that I shouldn't sit around and wait for the
TaskbarCreated
message?"
If the taskbar has already been created,
then your call to
Shell_
will
succeed
(assuming you didn't mess up and pass invalid parameters),
at which point you don't need to wait for the
NotifyIcon
TaskbarCreated
message
because you already created your notification icon.
Monitoring the system cursor is the wrong approach because the system cursor can be an hourglass for other reasons, and it can be an arrow even though the taskbar isn't ready.