Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
How do you prevent a MFC dialog from exiting when the return key is hit? I have an edit box, I can type in changes OK But if I hit the return key, the dialog exits.

[edit]I think the OP means 'exit' not 'exist'[/edit]
Posted
Updated 4-Jan-11 22:25pm
v2
Comments
Sergey Alexandrovich Kryukov 4-Jan-11 18:46pm    
What does it mean and why?
Nithin Sundar 4-Jan-11 22:22pm    
Are you perhaps trying to say that you want the Return key to call the OnOk() method by default? I think it does that already right? Post what you have done till now. People will be able to help you better then.
Richard MacCutchan 5-Jan-11 4:27am    
Normal action for the return key is to action the Default button of the dialog, which is usually the OK button. See Espen Harlinn's answer below for solution.

1 solution

Add ES_WANTRETURN to the style for the edit.
Documented here Edit Control Styles[^]


Regards
Espen Harlinn
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900