在对话框中添加了一个richedit控件,对话框就不显示了
郁闷,我试图弹出一个对话框,步骤如下:
1.建立了一个对话框资源的模板
2.双击模板建立对应的类
3.包含头文件
4,弹出对话框,代码如下:
CAddTypeDlg dlg;
dlg.DoModal();
但是,却无法弹出对话框?
其他的对话框都可以,但就是这个对话框弹不出来,
是vc的毛病?还是其他什么呢?
1.建立了一个对话框资源的模板
2.双击模板建立对应的类
3.包含头文件
4,弹出对话框,代码如下:
CAddTypeDlg dlg;
dlg.DoModal();
但是,却无法弹出对话框?
其他的对话框都可以,但就是这个对话框弹不出来,
是vc的毛病?还是其他什么呢?
后来才发现,是添加了richEdit的问题,去掉就行了,但是不是解决方法,于是网上搜了一下,还真有:参考如下资料:
AfxInitRichEdit():
这样就好了,真是奇怪。
最后看到了MS的解释,属于官方的东西,比较正式,帖在这里。
If you are using a rich edit control in a dialog box (regardless whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program’s InitInstance member function. You do not need to call it for each time you display the dialog box, only the first time. You do not have to call AfxInitRichEdit if you are working with CRichEditView.
不过到底是为什么会这样,还是不明白,也不知道MFC内部是如何处理的,不过知道怎么做就是了。
在CxxxApp::InitInstance()中添加代码
AfxInitRichEdit();
在app的InitInstance中加入AfxRichEditInit()初始化richedit空间
初始化通用控件即可,InitCommonControl***或InitCommonControls皆可
AfxInitRichEdit();
在app的InitInstance中加入AfxRichEditInit()初始化richedit空间