创建一个对话框后默认自动创建确定和取消两个按钮
两个按钮的ID号不能变
ID为IDOK和IDCANCEL
否则改变后将出现如下的异常(Debug)
查找原因是:
void CSystemSetDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_BTN_SYS_INIT, m_initBt); DDX_Control(pDX, IDOK, m_okBt); DDX_Control(pDX, IDCANCEL, m_cancelBt);}
ID号不对
BEGIN_MESSAGE_MAP(CSystemSetDlg, CDialog) ON_WM_PAINT() ON_BN_CLICKED(IDC_SYS_OK, &CSystemSetDlg::OnBnClickedSysOk) ON_BN_CLICKED(IDC_SYS_NO, &CSystemSetDlg::OnBnClickedSysNo) ON_BN_CLICKED(IDC_BTN_SYS_INIT, &CSystemSetDlg::OnBnClickedBtnSysInit)END_MESSAGE_MAP()
所以ID号需要对应起来
此外创建窗体类的时候默认没有创建初始化窗体函数,需要手工增加
函数声明:
virtual BOOL OnInitDialog();
函数实现:
BOOL CSystemSetDlg::OnInitDialog(){ CDialog::OnInitDialog();
return TRUE;
}