CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Shell_NotifyIcon with NIF_INFO

    I made this new thread as I have now with my new code. This time its much simpler and smaller but the Balloon is still not working.

    Code:
    void CTrayIcon::SetTrayIcon (HWND hWnd)
    {
    	vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    	GetVersionEx(&vi);
    	
    	if (vi.dwMajorVersion >= 6)	{
    		nid.cbSize = sizeof(nid);
    		nid.uVersion = NOTIFYICON_VERSION_4;
    	}
    
    	else if (vi.dwMajorVersion >= 5)	{
    		nid.cbSize = NOTIFYICONDATA_V2_SIZE;
    		nid.uVersion = NOTIFYICON_VERSION;
    	}
    
    	Shell_NotifyIcon (NIM_SETVERSION, &nid);
    
    	nid.hWnd = hWnd;
    	nid.uID = 0;
    	nid.uCallbackMessage = NIF_MSG;
    	nid.hIcon = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_GBICO));
    	nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    	wcscpy_s(nid.szTip, sizeof(nid.szTip), L"myAppName");
    	
    	Shell_NotifyIcon (NIM_ADD, &nid);
    }
    
    
    void CTrayIcon::ShowBalloon (LPCTSTR szInfo)
    {
    	nid.uFlags = NIF_INFO;
    	nid.dwInfoFlags = NIIF_NONE;
    
    	wcscpy_s(nid.szInfo, sizeof(nid.szInfo), szInfo);
    	wcscpy_s(nid.szInfoTitle, sizeof(nid.szInfoTitle), L"myAppName");
    
    	Shell_NotifyIcon(NIM_MODIFY, &nid);
    }
    Last edited by hypheni; November 7th, 2010 at 07:47 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Shell_NotifyIcon with NIF_INFO

    Quote Originally Posted by hypheni View Post
    I made this new thread as I have now with my new code. This time its much simpler and smaller but the Balloon is still not working.

    Code:
    void CGBDialog::ShowBalloon (LPCTSTR szInfo)
    {
    	nid.uFlags = NIF_INFO;
    	wcscpy_s(nid.szInfo, sizeof(nid.szInfo), szInfo);
    	nid.uTimeout = 6000;
    
    	Shell_NotifyIcon(NIM_MODIFY, &nid);
    }
    
    ShowBalloon (L"Balloon Tip shown");  //Not working.
    Wouldn't you like to change this red line to
    Code:
    	nid.uFlags |= NIF_INFO;
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    Still same, not working.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Shell_NotifyIcon with NIF_INFO

    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    I cant understand whats wrong in my code

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Shell_NotifyIcon with NIF_INFO

    in what system (2000, XP, Vista, ...) do you have this problem?
    Did you read about NOTIFYICONDATA Structure?
    Victor Nijegorodov

  7. #7
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    Im using Xp.

  8. #8
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    Im digging up this old thread as this is related to TrayIcon again with same code.

    When Im building a Debug version of my application im getting a NIIF_ERROR icon in the Balloon tip though I have set value NIIF_NONE to dwInfoFlags.

    ie:
    nid.dwInfoFlags = NIIF_NONE;

    but if I build a release version its fine.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Shell_NotifyIcon with NIF_INFO

    Quote Originally Posted by hypheni View Post
    Im digging up this old thread as this is related to TrayIcon again with same code.

    When Im building a Debug version of my application im getting a NIIF_ERROR icon in the Balloon tip though I have set value NIIF_NONE to dwInfoFlags.

    ie:
    nid.dwInfoFlags = NIIF_NONE;
    Either the code is NOT the same as you posted or there is not such a line there.

    Please, post your actual code .
    Victor Nijegorodov

  10. #10
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    I have updated the code with my actual one.. please check my 1st post

  11. #11
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    Any fixes ?

  12. #12
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Shell_NotifyIcon with NIF_INFO

    This question was asked and answered about a week ago. Search this forum for "Shell_NotifyIcon".

  13. #13
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    No, that thread was about creating Tray icon with balloon, and this problem is regarding balloon icon ie: nid.dwInfoFlags = NIIF_NONE in debug build.

    Please have a look on my 5th post..

    Im digging up this old thread as this is related to TrayIcon again with same code.

    When Im building a Debug version of my application im getting a NIIF_ERROR icon in the Balloon tip though I have set value NIIF_NONE to dwInfoFlags.

    ie:
    nid.dwInfoFlags = NIIF_NONE;

    but if I build a release version its fine.

  14. #14
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Shell_NotifyIcon with NIF_INFO

    Quote Originally Posted by hypheni View Post
    No, that thread was about creating Tray icon with balloon, and this problem is regarding balloon icon ie: nid.dwInfoFlags = NIIF_NONE in debug build.

    Please have a look on my 5th post..
    Okay. Start with the code and project and ONLY change dwInfoFlags param to NIIF_NONE.

    Change no other code in the sample and see how it behaves.

    If it works as expected, compare the differences between the sample code and your code.

  15. #15
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shell_NotifyIcon with NIF_INFO

    Okay. Start with the code and project and ONLY change dwInfoFlags param to NIIF_NONE.

    Change no other code in the sample and see how it behaves.
    Sample code?. Are you talking about trying with my code in a new project ?.

    I tried that also, but same. In debug build the balloon shows a error icon while in release build its showing me correct icon what Im setting.

Page 1 of 2 12 LastLast

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