Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 17: Track-Based Controls



  1. Test the application and return to MSVC


16.2.3..Multiline Edit Boxes...........................................................................


By default, an edit box is used to display a single line of text. An edit box is referred to as
multiline when it can display its text on more than one line.

To create a multiline edit box, use the same Edit control as the above single line Edit box.
To make this a multiline edit box, set its Multiline property to True. To do this at run
time, add the ES_MULTILINE style to the CEdit. At design time, to make it obvious
that the control can display more than one line of text, heighten it:

If the user is typing text in an edit control and press Enter, the control, usually a button,
that is the default would be activated. This feature is valuable for a single line edit box. If
you are creating a multiline edit box, you should allow the user to press Enter while
entering text into the control. This would prevent the default button from being activated
and would transfer the caret to the next line. To provide this functionality, add the
ES_WANTRETURN style or, at design time, set the Want Return property to True.

If the text of the edit control is longer than the edit control can display at one time, you
should equip it with scroll bars. To do this, at design time, set the Horizontal and/or the
Vertical Scroll properties to True. At run time, add the WS_HSCROLL and/or the
WS_VSCROLL properties.

Practical Learning: Designing Edit Boxes



  1. Reopen the Clarksville Ice Scream1 application and display the form

  2. Add an Edit Control at the bottom section of the form

  3. On the Properties window, check the Multiline check box or set its value to True

  4. Check the Want Return check box or set its value to True

  5. Check the Vertical Scroll check box or set its value to True

  6. Check the Modal Frame check box or set its value to True:

Free download pdf