|
-
August 12th, 1999, 10:25 AM
#1
response to carriage return in Edit control
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?
-
August 12th, 1999, 11:23 AM
#2
Re: response to carriage return in Edit control
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
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
August 12th, 1999, 12:26 PM
#3
Re: response to carriage return in Edit control
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?
-
August 12th, 1999, 04:11 PM
#4
Re: response to carriage return in Edit control
-
August 13th, 1999, 03:17 AM
#5
Re: response to carriage return in Edit control
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
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|