#define WM_NOTIFYICON WM_USER + 5
#define IDI_ICON 0x0005
fx_msg LRESULT OnNotifyIcon(WPARAM wParam,LPARAM lParam);
NOTIFYICONDATA nd;
nd.cbSize = sizeof (NOTIFYICONDATA);nd.hWnd = m_hWnd;
nd.uID = IDI_ICON;
nd.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
nd.uCallbackMessage= WM_NOTIFYICON;
nd.hIcon = m_hIcon;
lstrcpy(nd.szTip, _T("数据采集"));
Shell_NotifyIcon(NIM_ADD, &nd);
LRESULT CclientDlg::OnNotifyIcon(WPARAM wParam,LPARAM lParam)
{
if(wParam == IDI_ICON && lParam == WM_LBUTTONDBLCLK) //左击弹出对话框
ShowWindow(SW_NORMAL); //就是从最大化或者最小化的状态回复到B
if(wParam == IDI_ICON && lParam == WM_RBUTTONDOWN) //右击弹出弹出式菜单
{
CMenu *pMenu = NULL;
pMenu = myPopMenu.GetSubMenu(0);
CPoint point;
GetCursorPos(&point);
pMenu->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
}
return 0;
}
//当最小化时,状态栏不显示,只是显示托盘
void CclientDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
if(nID == SC_MAXIMIZE)
return;
if(nID == SC_MINIMIZE)
ShowWindow(SW_HIDE);
else
CDialogEx::OnSysCommand(nID, lParam);
}
}