1.让自己所编软件的图标显示在 taskbar status area(任务栏)处
创建一个基于对话框的MFC程序HelloWorld,在CHelloWorldDlg类中新建一个成员函数void InitNotifyIconData(void)。其具体实现如下
void CsupernotepadDlg::InitNotifyIconData(void)
{
/*NOTIFYCONDATA structure contains the information that the system
needs to process taskbar status area message*/
NOTIFYICONDATA nd;
//the size of this structure,in bytes
nd.cbSize = sizeof(NOTIFYICONDATA);
//a handle to the window that receives the notification message associated with an icon in the taskbar status area
nd.hWnd = m_hWnd;
//the application-defined identifier of the taskbar icon
nd.uID = IDR_MAINFRAME;
//Flags that indicate which of the other members contain valid data
nd.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
// is the identif

本文介绍了如何在MFC程序中创建任务栏图标并添加托盘菜单。通过`InitNotifyIconData`函数设置图标和提示信息,并在用户交互时响应自定义消息`WM_SHELLNOTIFY`,实现右键菜单和左键点击的相应功能。在程序关闭时,使用`OnDestroy`函数删除图标,确保干净退出。此外,还展示了在最小化窗口时如何隐藏窗口。
最低0.47元/天 解锁文章
290

被折叠的 条评论
为什么被折叠?



