将一个对话框资源及文件 从一个工程(正常运行)拷贝到另一个工程,所有变量及资源ID、代码都一样,为什么拷贝后这个对话框的数据交换函数出错?
出错时是调试器显示代码是这样的
HWND CDataExchange::PrepareCtrl(int nIDC)
{
ASSERT(nIDC != 0);
ASSERT(nIDC != -1); // not allowed
HWND hWndCtrl;
m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if (hWndCtrl == NULL)
{
TRACE1("Error: no data exchange control with ID
0x%04X.\n", nIDC);
指针在该处 -> ASSERT(FALSE);
AfxThrowNotSupportedException();
}
m_hWndLastControl = hWndCtrl;
m_bEditLastControl = FALSE; // not an edit item by default
ASSERT(hWndCtrl != NULL); // never return NULL handle
return hWndCtrl;
}///////////////////
数据交换函数是这样的:
void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRunToRepair)
DDX_Control(pDX, IDC_STATIC_QIHUAN, m_a);
DDX_Control(pDX, IDC_STATIC_BEGIN, m_b);
DDX_Control(pDX, IDC_EDIT1, m_c);
DDX_Control(pDX, IDCANCEL, m_d);
DDX_Control(pDX, IDC_BUTTON3, m_e);
DDX_Control(pDX, IDC_BUTTON2, m_f);
DDX_Control(pDX, IDC_BUTTON1, m_g);
DDX_Control(pDX, IDC_COMBO75, m_h);
DDX_CBIndex(pDX, IDC_COMBO75, m_i);
DDX_Text(pDX, IDC_EDIT1, m_j);
DDX_Text(pDX, IDC_EDIT2, m_k);
DDX_Text(pDX, IDC_EDIT3, m_l);
//}}AFX_DATA_MAP
}
出错时是调试器显示代码是这样的
HWND CDataExchange::PrepareCtrl(int nIDC)
{
ASSERT(nIDC != 0);
ASSERT(nIDC != -1); // not allowed
HWND hWndCtrl;
m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if (hWndCtrl == NULL)
{
TRACE1("Error: no data exchange control with ID
0x%04X.\n", nIDC);
指针在该处 -> ASSERT(FALSE);
AfxThrowNotSupportedException();
}
m_hWndLastControl = hWndCtrl;
m_bEditLastControl = FALSE; // not an edit item by default
ASSERT(hWndCtrl != NULL); // never return NULL handle
return hWndCtrl;
}///////////////////
数据交换函数是这样的:
void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRunToRepair)
DDX_Control(pDX, IDC_STATIC_QIHUAN, m_a);
DDX_Control(pDX, IDC_STATIC_BEGIN, m_b);
DDX_Control(pDX, IDC_EDIT1, m_c);
DDX_Control(pDX, IDCANCEL, m_d);
DDX_Control(pDX, IDC_BUTTON3, m_e);
DDX_Control(pDX, IDC_BUTTON2, m_f);
DDX_Control(pDX, IDC_BUTTON1, m_g);
DDX_Control(pDX, IDC_COMBO75, m_h);
DDX_CBIndex(pDX, IDC_COMBO75, m_i);
DDX_Text(pDX, IDC_EDIT1, m_j);
DDX_Text(pDX, IDC_EDIT2, m_k);
DDX_Text(pDX, IDC_EDIT3, m_l);
//}}AFX_DATA_MAP
}
问题依然存在……
有重复的,可是以前为什么不出问题呢,我还以为可以重复。能在Resource.h里直接改成不重复的吗(随便给个ID号)?
如果我把所有的变量都注掉,在调用这个对话框时,弹出的竟然是一个毫不相干的对话框!我晕……
还是不行……