zhuang
August 12th, 1999, 10:25 AM
I'd like to do something when the text in an Edit control is entered and the return is hit. What message I have to handle?
|
Click to See Complete Forum and Search --> : response to carriage return in Edit control zhuang August 12th, 1999, 10:25 AM I'd like to do something when the text in an Edit control is entered and the return is hit. What message I have to handle? Roger Allen August 12th, 1999, 11:23 AM You have to place your code in the PreTranslateMessage() function as follows : // looking for keydown message, where key is ENTER // and the focus is on the edit control in question if (pMSG->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN && GetFocus() == GetDlgItem(IDC_EDIT_CONTROL_ID)) { // enter pressed in the edit control, handle it here return true ; } return BaseClass::PreTranslateMessage() Roger Allen zhuang August 12th, 1999, 12:26 PM The code would close the Dialog after pressing enter. But I'd like to keep the dialog open after hitting enter in the Edit control. Any further idea? Rail Jon Rogut August 12th, 1999, 04:11 PM Check out Example 5 at http://home.earthlink.net/~railro/mfc_link.html. Rail Recording Engineer/Software Developer Rail Jon Rogut Software railro@earthlink.net http://home.earthlink.net/~railro/ Roger Allen August 13th, 1999, 03:17 AM The code I posted will only intercept the ENTER key when th focus is on the edit control, to stop ENTER fromclosing your dialog box, you will need to override the OnOK() function, as pressing ENTER is mapped to this control if the default button in your dialog is the IDOK button. IF you do override it, you will have to decide when to call the base class OnOK() to close the dislog box. Roger Allen codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |