Click to See Complete Forum and Search --> : to recreate the system tray icon when explorer crashes
myaman
July 26th, 2004, 09:13 AM
How to recreate the system tray icon when explorer crashes ?
My application shows an icon in System tray. But if the explorer.exe crashes and again i start explorer.exe from task manager, the icon fails to show up in the task bar.
Any idea how to recreate the icon ?
Aman
myaman
July 27th, 2004, 01:45 AM
Any idea how to bring the icon again in systray once explorer.exe crashes
RCFox
July 27th, 2004, 02:03 AM
Well... I know that with Win98, if that happens, I close an app and then call it up again. The icon shows again. Don't know if this is helpful in your case.
myaman
July 27th, 2004, 02:08 AM
I also dont want to restart my application,
U might have observer that icons for Yahoo messanger and MSN, and Outlook etc comes by itself in the systray after explorer.exe is started again. I want the same thing for my application.
NoHero
July 27th, 2004, 02:26 AM
look at this code from the msdn:
UINT s_uTaskbarRestart = 0;
s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
the explorer registers this message to notify each window of an taskbar refresh. If the message occures you have to repaint your tray icon:
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam,
LPARAM lParam)
{
static UINT s_uTaskbarRestart;
switch(uMessage)
{
case WM_CREATE:
s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
break;
default:
if(uMessage == s_uTaskbarRestart)
AddTaskbarIcons();
break;
}
return DefWindowProc(hWnd, uMessage, wParam, lParam);
}
hope this helps
myaman
July 27th, 2004, 03:36 AM
The DefWindowProc is giving following error
'DefWindowProcA' : no overloaded function takes 4 parameters
NoHero
July 27th, 2004, 03:56 AM
and using ...
::DefWindowProc( /* parameter in here */ );
... ?
its strange beauce the DefWindowProc HAS 4 parameters ... :confused:
usman999_1
July 27th, 2004, 05:16 AM
The DefWindowProc is giving following error
'DefWindowProcA' : no overloaded function takes 4 parameters
The compiler is trying to invoke CWnd::DefWindowProc either do
::DefWindowProc(hWnd, uMessage, wParam, lParam); // Note the :: before the function.
Or do something like
DefWindowProc(uMessage, wParam, lParam);
Hope this helps,
Regards,
Usman.
NoHero
July 27th, 2004, 05:21 AM
The compiler is trying to invoke CWnd::DefWindowProc either do
::DefWindowProc(hWnd, uMessage, wParam, lParam); // Note the :: before the function.
Or do something like
DefWindowProc(uMessage, wParam, lParam);
Hope this helps,
Regards,
Usman.
take a look at my last post ;)
usman999_1
July 27th, 2004, 05:26 AM
Well HERO dont you think if the person knew the difference between the global & instance functions, he wouldn't have asked in the first place. I can only say your last post don't go far enough ;).
Kind Regards,
Usman.
NoHero
July 27th, 2004, 05:31 AM
Well HERO dont you think if the person knew the difference between the global & instance functions, he wouldn't have asked in the first place. I can only say your last post don't go far enough ;).
Kind Regards,
Usman.
Ok, thats right ...
p.s.: NOhero ... I hate compliments about my name, by just remove the "no" ... ;)
myaman
July 27th, 2004, 05:43 AM
Actually i handled WM_CREATE message in OnCreate metfod and used
WM_TASKBARCREATED = ::RegisterWindowMessage(_T("TaskbarCreated"));
then i handled WM_TASKBARCREATED message to add the icon to the task bar.
But this time Shell_NotifyIcon(NIM_ADD, &m_nid); returns false.
I dont know WHY????
I am using a common function to add icon in systray say AddIconSysTray both from OnCreate and TASKBARCREATED handler
Any idea why Shell_NotifyIcon(NIM_ADD, &m_nid); is facing second time.
NoHero
July 27th, 2004, 06:04 AM
Actually i handled WM_CREATE message in OnCreate metfod and used
WM_TASKBARCREATED = ::RegisterWindowMessage(_T("TaskbarCreated"));
then i handled WM_TASKBARCREATED message to add the icon to the task bar.
But this time Shell_NotifyIcon(NIM_ADD, &m_nid); returns false.
I dont know WHY????
I am using a common function to add icon in systray say AddIconSysTray both from OnCreate and TASKBARCREATED handler
Any idea why Shell_NotifyIcon(NIM_ADD, &m_nid); is facing second time.
try incrementing the iID member of the NOTFIYICONDATA structure as long as Shell_NotifyIcon returns false. That helped in my case, but I can give a hint: I wrote a programm severel months ago, using a taskbar icon including refreshing it. Its open source, so if you want it, I give it to you. its using a class to provide Shell Icon handling. Do you want/need it?
myaman
July 27th, 2004, 12:07 PM
Thanks NoHero (see this time NO is removed from ur name :wave: )
Its working now, but still if share the code it can help me in any other way
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.