ES_WANTRETURN Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box's default push button. This style has no effect on a single-line edit control.
{
CString str;
GetDlgItem(IDD_EDITA)->GetWindowText(str);
GetDlgItem(IDD_EDITB)->SetWindowText(str);//B文本框显示A文本框的字母!
m_list.SetItemText(0,1,str);//m_ListCtrl里面输入数据return 1;
}
需要补充的是要通过pMsg参数判断,控件是不是你要操作的控件
Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box's default push button. This style has no effect on a single-line edit control.
2、响应WM_CHAR事件
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
// AfxMessageBox( "go into OnChar()" );
switch( nChar )
{
case VK_RETURN:
AfxMessageBox( "you pressed return key." );
break;
default:
break;
} CEdit::OnChar(nChar, nRepCnt, nFlags);
}
3、动态创建CMyEdit对象
CRect rc;
GetClientRect( &rc );
//ClientToScreen( &rc );
//ScreenToClient( &rc );
CRect rcEdit;
rcEdit.left = rc.left + 100;
rcEdit.top = rc.top + 100;
rcEdit.bottom = rcEdit.top + 100;
rcEdit.right = rcEdit.left + 300; CMyEdit* cme = new CMyEdit();
cme->Create( ES_LEFT|ES_MULTILINE, rcEdit, this, 10000 );
cme->ShowWindow( TRUE );
2、响应WM_CHAR事件
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
// AfxMessageBox( "go into OnChar()" );
switch( nChar )
{
case VK_RETURN:
AfxMessageBox( "you pressed return key." );
break;
default:
break;
} CEdit::OnChar(nChar, nRepCnt, nFlags);
}
3、动态创建CMyEdit对象
CRect rc;
GetClientRect( &rc );
//ClientToScreen( &rc );
//ScreenToClient( &rc );
CRect rcEdit;
rcEdit.left = rc.left + 100;
rcEdit.top = rc.top + 100;
rcEdit.bottom = rcEdit.top + 100;
rcEdit.right = rcEdit.left + 300; CMyEdit* cme = new CMyEdit();
cme->Create( ES_LEFT|ES_MULTILINE, rcEdit, this, 10000 );
cme->ShowWindow( TRUE );