对话框未返回-1 [英] Dialog box is not returning -1

查看:73
本文介绍了对话框未返回-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经完成了以下代码来创建一个对话框。



EditComPort.h



Hi,
I have done the following code to create a dialog box.

EditComPort.h

#pragma once
#include"resource.h"
#include<afxdialogex.h>
// CEDitComPort dialog

class CEDitComPort : public CDialogEx
{
    DECLARE_DYNAMIC(CEDitComPort)

public:
    CEDitComPort(CWnd* pParent = NULL);   // standard constructor
    virtual ~CEDitComPort();

// Dialog Data
    enum { IDD = IDD_EDIT_COM_PORT };

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    DECLARE_MESSAGE_MAP()
};





EditComPort.cpp



EditComPort.cpp

#include "stdafx.h"
#include "MfgTool.h"
#include "EDitComPort.h"



// CEDitComPort dialog

IMPLEMENT_DYNAMIC(CEDitComPort, CDialogEx)

CEDitComPort::CEDitComPort(CWnd* pParent /*=NULL*/)
    : CDialogEx(CEDitComPort::IDD, pParent)
{

}

CEDitComPort::~CEDitComPort()
{
}

void CEDitComPort::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CEDitComPort, CDialogEx)
END_MESSAGE_MAP()


// CEDitComPort message handlers





致电对话框





Call to the Dialogbox

void CMainFrame::OnEditComPort()
{
    // TODO: Add your command handler code here
    CEDitComPort dlg;
    int x=dlg.DoModal();//Here dlg.DoModal is returing -1
}





我的代码出了什么问题为什么dlg.DoModal返回-1



what is wrong with my code why dlg.DoModal is returning -1

推荐答案

文档 [ ^ ]声明当函数无法创建对话框时, DoModal 返回值为 -1 。为了发现这种失败背后的实际原因,我怀疑你必须在 MFC 来源上使用调试器。
The documentation[^] states that DoModal return value is -1 when the function cannot create the dialog. To discover the actual reason behind such a failure, I suspect you have to use the debugger on the MFC sources.


这篇关于对话框未返回-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆