Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   System tray icon gets disappear when explorer is killed (http://www.go4expert.com/forums/tray-icon-disappear-explorer-killed-t4659/)

gugaliashashank 13Jun2007 14:41

System tray icon gets disappear when explorer is killed
 
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;
}


shabbir 13Jun2007 17:38

Re: System tray icon gets disappear when explorer is killed
 
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.

gugaliashashank 16Jun2007 16:33

Re: System tray icon gets disappear when explorer is killed
 
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

shabbir 17Jun2007 08:51

Re: System tray icon gets disappear when explorer is killed
 
How you are trying to catch? Are you using the SPY?

gugaliashashank 17Jun2007 12:28

Re: System tray icon gets disappear when explorer is killed
 
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.

shabbir 17Jun2007 12:33

Re: System tray icon gets disappear when explorer is killed
 
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.


All times are GMT +5.5. The time now is 07:32.