Click to See Complete Forum and Search --> : System Tray Icon Question


Nathan Strandberg
April 9th, 1999, 02:46 PM
I have added the icon to the system tray, but how can I tell if the user right clicks on the icon? How about if they left click it?

Thanks,
Nathan Standberg

Ronny Guenther
April 9th, 1999, 03:55 PM
Hi Nathan.

When creating the tray icon you can specify a callback message that will be send
to your window when the user clicks (or whatever) on your icon.

See: NOTIFYICONDATA m_nid;
m_nid.cbSize = sizeof(m_nid);
m_nid.hWnd = this->m_hWnd;
m_nid.uID = 1;
m_nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
m_nid.uCallbackMessage = WM_TASKBAR; // <--- The message
strTip.LoadString(IDS_TIP);
strcpy(m_nid.szTip, strTip);
m_nid.hIcon = m_hIcon = AfxGetApp()->LoadIcon(IDI_ACTIVE);

All you've got to do now is catch the message and react in a proper way:


Hope this helps

Regards Ronny