我编了一个程序,用到编辑控件的数值输入方式,当不输入或输入数值太大时,都会弹出
“请输入整数”对话框,不知道怎么对话框修改内容。
另外,EN_CHANGE消息时,用了UpdateData(TRUE);函数,结果程序一启动,就谈出“请输入整数”对话框,我跟踪了一下,是因为输入字符串不能转化为整数,
我不明白,我还没有输入,怎么就有EN_CHANGE消息,
还有就是怎么避免这个对话框,
程序如下:void CCommForm::OnChangeCurrentContral()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CFormView::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_CHANGE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
TRACE("\n\n\nIn void CCommForm::OnChangeVoltContral() ");
TRACE("m_byVolt_contral=%d",m_byVolt_contral);
MessageBox("In void CCommForm::OnChangeCurrentContral()","need write",MB_ICONINFORMATION);
}
“请输入整数”对话框,不知道怎么对话框修改内容。
另外,EN_CHANGE消息时,用了UpdateData(TRUE);函数,结果程序一启动,就谈出“请输入整数”对话框,我跟踪了一下,是因为输入字符串不能转化为整数,
我不明白,我还没有输入,怎么就有EN_CHANGE消息,
还有就是怎么避免这个对话框,
程序如下:void CCommForm::OnChangeCurrentContral()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CFormView::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_CHANGE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
TRACE("\n\n\nIn void CCommForm::OnChangeVoltContral() ");
TRACE("m_byVolt_contral=%d",m_byVolt_contral);
MessageBox("In void CCommForm::OnChangeCurrentContral()","need write",MB_ICONINFORMATION);
}
也就是和整形数的绑定,你可以绑定成一个CEdit,然后再GetWindowText
void CCommForm::OnInitialUpdate()还要早,这样程序就会先调用OnChange函数
里的UpdateData(TRUE)函数而不是接着 void CCommForm::OnInitialUpdate()
的UpdateData(FALSE),这样的话,在构造函数初始化的与控件绑定的变量就会被UpdateData(TRUE)覆盖,我和我想的正好相反,我想的是先调用UpdateData(FALSE),初始化控件显示的。不过在我这个程序中,第一次调用UpdateData(TRUE)(就是程序启动是的那次)会因为输入数据类型不符而调用失败,所以开始时构造函数初始化的数据并没有被覆盖,程序启动以后仍能正常运行,就是在启动时会有“请键入整数”对话框,瞒烦
你响应自己的EN_CHANGE地时候,不要使用UpdateData,而是使用SetWindowText方式,改变控件当中的内容就可以了。