CDialog_DoModal返回-1,无法创建Dialog

CDialog::DoModal

Return Value:

An int value that specifies the value of the nResult parameter that was passed to the CDialog::EndDialog member function, which is used to close the dialog box. The return value is –1 if the function could not create the dialog box, or IDABORT if some other error occurred, in which case the Output window will contain error information from GetLastError.

DoModal无法创建对话框的原因,主要有一下几种:

1 父窗口句柄(HWND)无效。

2 在OnInitDialog里用了ENDDIALOG或OnOK等。

3 存在无效的对话框资源ID。

4 使用没有注册的的自定义控件。

5 对话框的某些控件创建失败,如RICHEDIT,要加上AfxInitRichEdit();。

最有可能出现的是第3条,也就是在资源文件中存在对话框的某个资源ID,但实际上对话框中并未摆放该控件,或者已经删除。

posted on 2012-11-15 10:34  zhuyf87  阅读(902)  评论(0编辑  收藏  举报

导航