Method:
- Select the want return attribute for the cedit that can be edited for multiple rows.
- For cedit of a single row, you need to reload onok () and oncancel ()
- Intercept the Enter key message
Select the attributes multiline and want return of the cedit control.
I used to encounter such a problem when I was just learning it. No one around me could use MFC (or csdn). At that time, I was very depressed. The current students are really happy. In fact, the reason is very simple: when you press enter, Windows will check the current input focus. If it is not on the button, you can see which button is the default one (the default attribute in the resource editor button ). If no default button is available, the application framework sends the message to the onok () virtual function in the dialog box. So you just need to reload this function. This is basically the same as that of the ms mvp.
The specific method is as follows:
1. Remove the default properties of the OK button.
2. Add a message processing function for the OK button. Onok ()
3. Remove cdialog: onok () from onok. // if your dialog box class is directly inherited from cdialog
4. Rename the OK button ID to idc_ OK.
5. Re-Add the message processing function for the OK button. Generally, it is named onclickedok (). Here is the function that the real processing button is pressed.
In this way, you can
I also encountered this problem at the beginning, as if it was related to the keyboard response function of the program.
This function is added to the message in the Class Wizard.
Bool cserverdlg: pretranslatemessage (MSG * PMSG)
{
// Todo: add your specialized code here and/or call the base class
If (PMSG-> message = wm_keydown & PMSG-> wparam = vk_return)
{
// Add the action you want the program to take after receiving the Keyboard Message.
Return true;
}
Return cdialog: pretranslatemessage (PMSG );
}