Re: System tray menu questions.
On Mar 17, 8:55 pm, "Tom Serface" <t...@camaswood.com> wrote:
PJ has had this for a while, but the technology hasn't changed much in th=
e
last years so it still works really well. Worth a look anyway.
Tm
"dushkin" <talt...@gmail.com> wrote in message
news:81012ed3-aa95-4c27-b2ac-846c742f8324@g11g2000yqe.googlegroups.com...
Seems to be great! I will check it. Thanks!
Did you really maintained this package 11 years?!?!
:-)
Tom, I used your classes. Same results.
Here are the relevant code sections:
CTrayNotifyIcon g_TrayIcon1;
BEGIN_MESSAGE_MAP(CVPGAgentDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_COMMAND(ID_AGENTMENU_CLOSE, OnAgentClose)
ON_MESSAGE(WM_TRAYNOTIFY, OnTrayNotification)
END_MESSAGE_MAP()
void CVPGAgentDlg::OnAgentClose()
{
//AfxMessageBox("a");
PostMessage(WM_CLOSE);
}
void CVPGAgentDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
m_autoLog.Close();
}
int CVPGAgentDlg::CreateTrayIcon(void)
{
if (!g_TrayIcon1.Create(this, IDR_MENU1, _T("PA Automation Agent"),
m_hIcons[0], WM_TRAYNOTIFY))
{
AfxMessageBox(_T("Failed to create tray icon"), MB_OK |
MB_ICONSTOP);
return -1;
}
//For testing purposes, change the default menu item on the first
icon to be the bottom item on the context menu
g_TrayIcon1.SetDefaultMenuItem(ID_APP_ABOUT, FALSE);
return 0;
}
LRESULT CVPGAgentDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
//Delegate all the work back to the default implementation in
//CTrayNotifyIcon.
g_TrayIcon1.OnTrayNotification(wParam, lParam);
return 0L;
}