Hi All I am using a win32 API Code: BOOL Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATA lpdata ); to create the icon in system tray. When i kill the explorer and restart it again my icon disappears from the system tray but the application is running which i can see in task manager.How i can prevent the icon from disappearing. I am creating the icon in WM_CREATE Message of my window procedure Code: static NOTIFYICONDATA ni; WM_CREATE: { hIcon =(HICON) LoadImage( NULL, "pcclient.ico",IMAGE_ICON, 0, 0, LR_LOADFROMFILE) ; (void) memset(&ni, 0, sizeof(ni)); ni.cbSize = sizeof(ni); ni.uID = 106; ni.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; ni.hIcon = hIcon; ni.hWnd = hwnd; strcpy(ni.szTip,"PC Client"); ni.uCallbackMessage = WM_APP ; Shell_NotifyIcon( NIM_ADD , &ni); return true; } WM_CLOSE: { Shell_NotifyIcon(NIM_DELETE, &ni); return true; }
See what message you get when the explorer is killed and when again its restarted and have similar thing in that messages to have the icon in the tray.
Thanks Shabbir for your suggestion but i too tried to catch the message but i am not able to catch that which message is being called when the explorer is being killed from the task manager
no i am not using spy what i am doing is that i was trying to print the message number when i killed the exe from the explorer but my wndproc is not even called when this case occur Can u plese tell me how to catch the event thru the spy.
With the Spy you find the Window and see what are messages passed. Remember to see out the Mouse messages or you will see all the messages being shown and you may loose the messages. I am not sure if you will be able to see the window because when you close the Explorer your SPY window may also get closed but you can try. As far as I can think off it should be something like WM_QUIT or something similar message.