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
Printable View
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
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