CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2003
    Posts
    18

    System tray icon of my application disappears, when Windows Explorer crashes.

    System tray icon of my application disappears, when Windows Explorer crashes. ( After that I again re creates Windows Explorer. But my system tray icon of my application doesn't reappear.)
    Which message will Windows Taskbar generate to restore the system tray icons.?

    Can anyone please help me to solve this problem.

  2. #2
    Join Date
    Sep 2003
    Posts
    18

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Following is the code I used. Please check if there are some problems in it.

    NOTIFYICONDATA iconData;
    iconData.cbSize = sizeof(NOTIFYICONDATA);
    iconData.hWnd = this->m_hWnd;
    iconData.uID = IDR_MAINFRAME;
    iconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP ;
    iconData.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE (IDI_ICON1), IMAGE_ICON, 16, 16, LR_VGACOLOR);
    iconData.uCallbackMessage = WM_NOTIFYICON;

    CString str;
    str.LoadString(IDS_STR_ICON);

    strcpy(iconData.szTip, str);

    BOOL ret = Shell_NotifyIcon(NIM_ADD, &iconData);

  3. #3
    Join Date
    Oct 2002
    Location
    Italy
    Posts
    324

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Probably it's not an issue of your application but of the system tray itself, as icons from all other programs disappear as well. Maybe you can add a hook and create your icon when the taskbar is back again?
    Regards,
    Marco Era
    www.marcoera.com

    Latest post on my blog: Back to the Amiga's times

  4. #4
    Join Date
    Jul 2005
    Posts
    767

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Hah but your why does Windows Explorer crash in the first place?
    Try to investigate as to why the Explorer crashs...if it due to some faulty code you wrote (I wonder how!)...then you should correct your code else leave this problem...since it is not your job to take of what happens upon a windows component (say Windows Explorer in this case) crash

  5. #5
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    No needs for any hooks. Windows has a build-in feature to notify you when the notification area is recreated.
    First register the following message:
    Code:
    UINT m_nWMTaskBarCreated = ::RegisterWindowMessage(_T("TaskbarCreated"));
    Then in your windowproc you can do something like:
    Code:
    	if (uMsg == m_nWMTaskBarCreated)
    	{
    		InstallTrayIcons();
    		return 0;
    	}
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  6. #6
    Join Date
    Jul 2005
    Posts
    767

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Good one there Marc but could kindly tell me the source of this information. Thanks

  7. #7
    Join Date
    Sep 2003
    Posts
    18

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Thanks a lot Marc for helping me to solve this problem.
    This is an excellent solution.

  8. #8
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Good one there Marc but could kindly tell me the source of this information. Thanks
    MSDN has it, http://msdn.microsoft.com/library/en...asp?frame=true

  9. #9
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    A relevant read -
    Whenever Internet Explorer 4.0 starts the taskbar, it broadcasts a registered message TaskbarCreated to all top-level parent windows. This is your cue to recreate the icons. If you're using MFC, all you have to do is define a global variable to hold the registered message and implement an ON_REGISTERED_MESSAGE handler for it.

  10. #10
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: System tray icon of my application disappears, when Windows Explorer crashes.

    Quote Originally Posted by MrBeans
    Good one there Marc but could kindly tell me the source of this information. Thanks
    See the link posted by Krishnaa.
    Note that this will only work with Internet Explorer 4.0 and later, but that's almost all versions of Windows.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured