1.在OnInitDialog中加入:
// IDM_ABOUTBOX must be in the system command range.
ATLASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ATLASSERT(IDM_ABOUTBOX < 0xF000);
HMENU hMenu = GetSystemMenu(FALSE);
CMenu sysMenu(hMenu);
if (sysMenu.m_hMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
sysMenu.AppendMenu(MF_SEPARATOR);
sysMenu.AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
2.加入消息响应:
(1) MSG_WM_SYSCOMMAND(OnSysCommand)
(2)
void OnSysCommand( UINT nID, CPoint point)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
//很重要,使用缺省处理
SetMsgHandled(FALSE);
}
}