Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a multiline text in a static text control in mfc?

Tags:

visual-c++

mfc

I have a simple problem with my static text control. I want to write two sentences in two lines.

I searched everywhere, they answered that its style should not be simple and it should be big enough and then it can be done with \n or \r\n. Another guy wrote that it worked!

I did that, but it's not working! The caption is "Welcome to Genetic Algorithm Simulator Application.\nPlease Choose a Function:" but it just ignores \n and shows this: Welcome to Genetic Algorithm Simulator Application.Please Choose a Function:"

like image 630
Saman Hakimzadeh Abyaneh Avatar asked Jun 19 '12 19:06

Saman Hakimzadeh Abyaneh


3 Answers

Also keep in mind that if the "Center Image" style (SS_CENTERIMAGE) is applied (giving you vertical centering of the text), then "\r\n" character sequences are ignored.

like image 153
josh poley Avatar answered Sep 23 '22 01:09

josh poley


You should not set SS_SIMPLE style for static control. This is what is causing control to display only single line ignoring new line character. Get rid of this style and it will work.

like image 24
JohnCz Avatar answered Sep 24 '22 01:09

JohnCz


I tried it with MFC in VS2008, in the static text control properties set the property "No Wrap" to False and the text should be automatically wrapped to the size of the control.

like image 33
Jeeva Avatar answered Sep 27 '22 01:09

Jeeva