Win32 multi-line editing control loses carriage return in SetWindowText ()

In my C ++ Win32 GUI application, I have a dialog with an edit control created from a dialog template:

EDITTEXT   IDC_EDIT_Id, X, Y, W, H,
    ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL

Each time you enter multi-line text with a carriage return and call, the GetWindowText()resulting text is divided into lines with characters CRand LF, as expected. However, when I try to put the same text back into the edit control with SetWindowText(), the control displays that text as a single line.

Why does this show such behavior and how can I solve it?

+3
source share
1 answer

SetWindowText, , \r\n .

.

:

GetDlgItem(IDC_EDIT1)->SetWindowText(_T("Hello\r\nWorld!"));


!

1 :

GetDlgItem(IDC_EDIT1)->SetWindowText(_T("Hello\nWorld!"));

HelloWorld!

+5

Source: https://habr.com/ru/post/1726257/


All Articles