QA: How can I create controls with multiline text?

Vassili Philippov (vasja@spbteam.com), September 14, 2001.

Question

I want to create an edit control with multiline text (or label control, or button control, etc). What should I do for that?

Answer

You should set Multiline flag in style and text in control should contain 'new line' symbols. For different controls you should use either \n or \r\n to divide lines. For button and edit controls use \r\n for all other control types use \n.

Multiline style

Use dialog editor to set multiline style for your controls.
Set multiline style in dialog editor

Multiline text

Here is a sample code that sets multiline text to different controls.

m_edit.SetWindowText(_T("Line one\r\nLine two")); m_label.SetWindowText(_T("Line one\nLine two")); m_check.SetWindowText(_T("Line one\nLine two")); m_radio.SetWindowText(_T("Line one\nLine two")); m_button.SetWindowText(_T("Line one\r\nLine two"));

Sample project

You could download sample project (48 Kb) that shows working with multiline text in different controls.