The EN_CHANGE notification is not sent when the ES_MULTILINE style is used and the text is sent through WM_SETTEXT. 你的两个编辑框都设置Multi-line属性void CXXDlg::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here static int i=0; m_text2.Format(_T("%d"), i++); GetDlgItem(IDC_EDIT2)->SetWindowText(m_text2); }void CXXDlg::OnChangeEdit2() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here static int i=0; m_text.Format(_T("%d"), i++); UpdateData(FALSE); }
另外一个对话框此时也会收到 ON_EN_CHANGE ,但由于判断没有焦点,所以直接返回。
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here static int i=0; m_text2.Format(_T("%d"), i++);
GetDlgItem(IDC_EDIT2)->SetWindowText(m_text2);
}void CXXDlg::OnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
static int i=0; m_text.Format(_T("%d"), i++);
UpdateData(FALSE);
}
GetDlgItem(IDC_EDIT1)->SetWindowText(m_text1);
你出现死循环的代码是???可以贴出来看看不void CTwoEditDataExchangeDlg::OnEnChangeEdit1()
{
// TODO: 如果该控件是 RICHEDIT 控件,则它将不会
// 发送该通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。 // TODO: 在此添加控件通知处理程序代码
CString str;
GetDlgItemText(IDC_EDIT1,str);
SetDlgItemText(IDC_EDIT2,str);
}