/*
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C4996 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. netcard_op d:visual studio 2015Projects
etcard_op
etcard_op
etcard_opDlg.cpp 187
//项目-》属性-》c/c++-》预处理器里面添加:
_CRT_SECURE_NO_WARNINGS
在BEGIN_MESSAGE_MAP(Cnetcard_opDlg, CDialogEx)下面添加
ON_MESSAGE(WM_SHOWTASK,onShowTask)
stdafx.h里面添加
#define WM_SHOWTASK WM_USER+1
*/MFC隐藏到托盘双击还原_右键退出实现方法
void Cnetcard_opDlg::ToTray() { NOTIFYICONDATA nid; nid.cbSize = (DWORD)sizeof(NOTIFYICONDATA); nid.hWnd = this->m_hWnd; nid.uID = IDR_MAINFRAME; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_SHOWTASK; nid.hIcon = LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MAINFRAME)); _tcscpy(nid.szTip, L"NetCard_Exhange"); Shell_NotifyIcon(NIM_ADD,&nid); ShowWindow(SW_HIDE); } LRESULT Cnetcard_opDlg::onShowTask(WPARAM wParam, LPARAM lParam) { if (wParam != IDR_MAINFRAME) return 1; switch (lParam) { case WM_RBUTTONUP://右键弹出菜单 { LPPOINT lpoint = new tagPOINT; ::GetCursorPos(lpoint);//获取鼠标位置 CMenu menu; menu.CreatePopupMenu(); menu.AppendMenu(MF_STRING,WM_DESTROY,L"Close"); menu.TrackPopupMenu(TPM_LEFTALIGN,lpoint->x,lpoint->y,this); //资源回收 HMENU hmenu = menu.Detach(); menu.DestroyMenu(); delete lpoint; } break; case WM_LBUTTONDBLCLK://双击左键 { this->ShowWindow(SW_SHOW); } break; default: break; } return LRESULT(); }