One Edit Box Likes \n, Other Requires \r\n

a_unique_name 401 Reputation points
2022-11-16T18:18:10.47+00:00

Hello Folks:

Developing on VS 2022 Community, C++.

Two modules I've developed to help debug my apps have multi line text controls where I display whatever text I think might help as I develop the app.

One edit control inserts a line feed when I send it a "\n" and the other ignores the line feed unless it comes in as a "\r\n".

It's kind of annoying that carefully formatted text displayed in one control looses its formatting when displayed in the other. I have code that will replace "\n" with "\r\n" but I'd rather figure out a way to avoid needing such a function.

The dialogs and edit controls were both defined in the Dialog Editor and the edit control properties for both look identical to me.

Neither edit control received a EM_SETENDOFLINE message but I've recently tested that feature to no effect. An EM_GETENDOFLINE message always seems to return 0, regardless of what I set the control's end of line to.

Any idea what I'm missing?

Thanks
Larry

Developer technologies | C++
{count} votes

Accepted answer
  1. Michael Taylor 60,346 Reputation points
    2022-11-16T20:12:16.713+00:00

    The built in Win32 edit control requires \r\n (Windows) for newline characters. It doesn't support the \n (Unix) variant. Also ensure that the control itself has multiline enabled otherwise they will both be ignored. When inserting text into the control that may have Unix newlines you have to convert them to Windows newlines.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.