本文主要是介绍MFC隐藏到托盘双击还原_右键退出实现方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 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 2015\Projects\netcard_op\netcard_op\netcard_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
*/
//
/*
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 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 2015\Projects\netcard_op\netcard_op\netcard_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
*/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();
}
这篇关于MFC隐藏到托盘双击还原_右键退出实现方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!