0

I have created edit control with the style ES_AUTOHSCROLL in my main window.

Documentation states that When the user presses the ENTER key, the control scrolls all text back to position zero.

I have entered very long text, positioned caret at the end of the text, and pressed enter.

Instead of documented text scrolling, all I heard was a beep.

Important: I have enabled Visual Styles. I have tested this on Windows 7.

QUESTION:

Is the beep normal behavior ( did Microsoft failed to update the documentation? ) or am I doing something wrong?

Community
  • 1
  • 1
AlwaysLearningNewStuff
  • 2,939
  • 3
  • 31
  • 84
  • Does your control have the `ES_MULTILINE` style? A single-line edit does not accept the ENTER key. – Remy Lebeau May 13 '15 at 15:17
  • 1
    @RemyLebeau: It is single line edit control. I do not need multiline style. From your comment I conclude that the official documentation was referring to the multiline edit control, but failed to explicitly state so. Is my conclusion correct? – AlwaysLearningNewStuff May 13 '15 at 15:26
  • @AlwaysLearningNewStuff I think it's an error in the documentation. It doesn't make sense for a single-line Edit control to scroll when pressing the Enter key. You always could report the documentation error to Microsoft or post your findings in the community section of that MSDN page. – jamesdlin May 14 '15 at 10:20
  • Did you specify the `ES_WANTRETURN` (or similar) control style? That would explain the beep you heard: You requested a keystroke that your control doesn't handle. – IInspectable May 14 '15 at 12:55
  • @IInspectable: *Did you specify the `ES_WANTRETURN`* Yes I have, still the same beep. – AlwaysLearningNewStuff May 14 '15 at 14:06
  • Don't use `ES_WANTRETURN` on a single-line edit control. See [Edit Control Styles](https://msdn.microsoft.com/en-us/library/windows/desktop/bb775464.aspx): *"This style has no effect on a single-line edit control."* For the whole ugly truth read this: [Just because you're a control doesn't mean that you're necessarily inside a dialog box](http://blogs.msdn.com/b/oldnewthing/archive/2007/08/20/4470527.aspx). – IInspectable May 14 '15 at 15:26

1 Answers1

1

In order to enable multiline mode for your Edit Box you need to create the control with the following flags: ES_MULTILINE and ES_WANTRETURN.

Andrew Komiagin
  • 6,446
  • 1
  • 13
  • 23
  • I do not need multiline edit control. I just do not understand which behavior is correct -> the one from the docs or the one I experience. Going through the comments and your answer, I believe that the documented behavior ( scroll text to the beginning ) is meant only for multiline edit controls... – AlwaysLearningNewStuff May 13 '15 at 15:28