1、在OnInitDialog中,或其它初始函数中加下:
//
注意,菜单的资源id的值是有讲究的,要定义成0x0**0的样子,在以下检查是否符合这个条件
ASSERT((IDM_ABOUTBOX
&
0xFFF0
)
==
IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX
<
0xF000
);
//
>0xF000的是系统定义的,所以俺们不能用
ASSERT((IDM_SET_AUDIO
&
0xFFF0
)
==
IDM_SET_AUDIO);
ASSERT(IDM_SET_AUDIO
<
0xF000
);
ASSERT((IDM_AUTO_ANSWER
&
0xFFF0
)
==
IDM_AUTO_ANSWER);
ASSERT(IDM_AUTO_ANSWER
<
0xF000
);
ASSERT((IDM_SET_TOP_MOST
&
0xFFF0
)
==
IDM_SET_TOP_MOST);
ASSERT(IDM_SET_TOP_MOST
<
0xF000
);
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
CMenu
*
pSysMenu
=
GetSystemMenu(FALSE);
if
(pSysMenu
!=
NULL)
{
CString strMenu;
pSysMenu->AppendMenu(MF_SEPARATOR);
strMenu.LoadString(IDS_SET_AUDIO); //在资源中的字符串中定义的
pSysMenu->AppendMenu(MF_STRING, IDM_SET_AUDIO, strMenu);
strMenu.LoadString(IDS_AUTO_ANSWER);
pSysMenu->AppendMenu(m_AutoAnswer ? MF_CHECKED:MF_UNCHECKED, IDM_AUTO_ANSWER, strMenu);
strMenu.LoadString(IDS_SET_TOP_MOST);
pSysMenu->AppendMenu(m_topMost ? MF_CHECKED:MF_UNCHECKED, IDM_SET_TOP_MOST, strMenu);
strMenu.LoadString(IDS_ABOUTBOX);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strMenu);
}
2、在OnSystemCommand中(注意这是个系统消息处理函数,所以要有消息映射机制)
if
((nID
&
0xFFF0
)
==
IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/0196c3df5ea9e936f21e9932cca91014.gif)
2、在OnSystemCommand中(注意这是个系统消息处理函数,所以要有消息映射机制)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/0196c3df5ea9e936f21e9932cca91014.gif)