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,但实际上对话框中并未摆放该控件,或者已经删除。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值