0

I have some problems to respond on a event like "Enter". I have a dialogbox with a CEdit field, where the user could enter some stuff. How could I respond, if the user press "Enter" in the textfield?

I will submit the content in the textfield to a function, if the user press the "Enter" key.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Andre Hofmeister
  • 3,185
  • 11
  • 51
  • 74

1 Answers1

1

If you're using the Visual Studio GUI editor, you can select the textbox, view the properties window, and set "Want Return" to "true". If you're creating the CEdit via code, you can pass ES_WANTRETURN to your CreateWindowEx function.

Also, this is a duplicate of How can I handle the Return key in a CEdit control? which has answers for non-GUI.

Community
  • 1
  • 1
Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
  • Okay. If i set "Want Return" to "true", what will be submit? Will the default button of the dialog executed? I tried the solution with "PreTranslateMessage", but the IDE told me, that my dialog ist not a main member of... I cant remember :). Btw, the dialog is based on "CPropertyPage". Does this matter? Greetz – Andre Hofmeister Aug 04 '11 at 16:51
  • If you set "Want Return" to true, you'll have to submit either with mouse, or tab then enter. – Mooing Duck Aug 04 '11 at 23:02
  • To make the dialog not accept enter and close, you'll have to set the Enter/OK button's "Default Button" member to "False". – Mooing Duck Aug 04 '11 at 23:04
  • Okay, thanks. I made it with the PreTranslateMessage function. – Andre Hofmeister Aug 05 '11 at 07:45