#define new DEBUG_NEW
static char THIS_FILE = __FILE__;
CTrayNot::CTrayNot ( CWnd* pWnd, UINT uCallbackMessage,
LPCTSTR szTip, HICON* pList )
// this is only for Windows 95 (or higher)
m_bEnabled = ( GetVersion() & 0xff ) >= 4 ;
// load up the NOTIFYICONDATA structure
m_tnd.cbSize = sizeof(NOTIFYICONDATA) ;
m_tnd.hWnd = pWnd->GetSafeHwnd() ;
m_tnd.uID = 0 ;
m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP ;
m_tnd.uCallbackMessage = uCallbackMessage;
strcpy ( m_tnd.szTip, "Tray Icon Sample - By Ashley Rowe");
//or you could use:
//strcpy ( m_tnd.szTip, AfxGetApp()->m_pszAppName);
//this will display the app name instead of the string you specify
// save the pointer to the icon list and set the initial
// default icon.
m_pIconList = pList ;
m_tnd.hIcon = m_pIconList ;
Shell_NotifyIcon (NIM_DELETE, &m_tnd);
void CTrayNot::SetState(int id)
m_tnd.hIcon = m_pIconList[id];
//Ive found in windows XP that this command makes the icon not visable in the system tray....we dont want that now
// Shell_NotifyIcon(NIM_MODIFY, &m_tnd);
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Name: Ash Rowe
From: Canberra, Australia
Qualifications: Diploma in Game Programming
Age: 19 (Getting old and feeling it)
Tutorials I have written in the past, I have done so in a fashion that would enable even the newest of programmers to get a grasp on what is actually happening with the code I submit. I am looking at writing even more in the near future to further assist others as well as gain a better understanding myself of the code I end up with.