一个CRichEdit,变量为m_RichEdit;
然后我响应回车键,为了实现按下回车换行,按下回车就执行下面的代码:
UpdateData(TRUE);
m_RichEdit += _T("\r\n");
GetDlgItem(IDC_RICHEDIT)->SetWindowText(m_RichEdit); 可是CRichEdit中怎么输入了2个回车?
如果我在代码里加一句MessageBox:
UpdateData(TRUE);
m_RichEdit+=_T("\r\n");
GetDlgItem(IDC_RICHEDIT)->SetWindowText(m_RichEdit);
MessageBox(_T("enter"));//加入这一句 这样就正常了,只有一个回车,请问,这是怎么回事?
还有一个问题,就是如何把光标定到最后面末尾处,现在输入回车后光标跑最前面去了
{
if(pMsg->wParam==VK_RETURN )//enter,聊天输入回车换行
{
UpdateData(true);
m_edit+=_T("1");
GetDlgItem(IDC_EDIT2)->SetWindowText(m_edit);
//MessageBox(_T("enter"));
return true;
}
return CDialog::PreTranslateMessage(pMsg);
}
这是完整的代码,不知道哪里出问题
屏蔽呢?
怎么响应的?
按下回车
加上
m_RichEdit += _T("\r\n");
不正好两个回车吗?
if(pMsg->wParam==VK_RETURN && pMsg->lParam == WM_KEYDOWN)