在MFC中,需要按以下方法处理:
BOOL CtestmfcDlg::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if(message == WM_INITDIALOG)
{
// 创建一个“完成”按钮并调整其大小。
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU;
shidi.hDlg = m_hWnd;
::SHInitDialog(&shidi);
::SHDoneButton(m_hWnd,SHDB_HIDE);
::SetWindowLong(m_hWnd,GWL_STYLE,WS_NONAVDONEBUTTON );
return (INT_PTR)TRUE;
}
return CDialog::OnWndMsg(message,wParam,lParam,pResult);
}
或者在直接在OnInitDialog里替换掉CDialog::OnInitDialog.
BOOL CtestmfcDlg::OnInitDialog()
{
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU;
shidi.hDlg = m_hWnd;
::SHInitDialog(&shidi);
::SHDoneButton(m_hWnd,SHDB_HIDE);
::SetWindowLong(m_hWnd,GWL_STYLE,WS_NONAVDONEBUTTON );
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
return TRUE; // 除非将焦点设置到控件,否则返回TRUE
}
参考:http://blog.csdn.net/czbever/article/details/4348150