VC对话框程序中直接使用RichEdit需要初始化

在VC中开发MFC对话框应用程序时,DoModal()返回-1,对话框无法显示,跟踪后发现DoModal()中的CreateDlgIndirect(lpDialogTemplate,
      CWnd::FromHandle(hWndParent), hInst)

失败,上网搜索一番终于找到了元首-RichEdit。在对话框上直接使用RichEdit控件时,在对话框的DoModal()之前需要先调用AfxInitRichEdit(),MSDN中是这样说的:

BOOL AFXAPI AfxInitRichEdit( );

Remarks

...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.

;