给对话框中加了一个复文本编辑控件,刚把界面资源设计完,代码还没添加,想运行看看效果,结果点了半天执行按钮,没报错也没反应。
现在知道要在应用程序初始化函数中添加AfxInitRichEdit()
Call this function to initialize the rich edit control for the application. It will also initialize the common controls library, if the library hasn’t already been initialized for the process. If you use the rich edit control directly from your MFC application, you should call this function to assure that MFC has properly initialized the rich edit control runtime. If you use rich edit via CRichEditCtrl, CRichEditView, or CRichEditDoc, you don 't need to call this function.
而且位置也要注意:
BOOL CSmtpApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CSmtpDlg dlg;
m_pMainWnd = &dlg;
AfxInitRichEdit();
int nResponse = dlg.DoModal();//在此句之后添加无效
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
DO.MODAL应该应该就是创建对话框的吧,AfxInitRichEdit()是在创健对话框之前初始化控件的,----