CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 16

Threaded View

  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.

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