1

How can I toggle word-wrap in a multiline EditBox?

I can create it with or without but I don't know which message I should use to toggle the wrapping mode.

2
  • 1
    Word-wrapping is controlled by a word-break procedure set by the EM_SETWORDBREAKPROC window message. Or, maybe you are thinking of "soft" word-wrapping? That is set using the EM_FMTLINES window message. See Handling Wordwrap and Line Breaks for more details. Jun 26, 2019 at 22:06
  • 1
    For EM_FMTLINES MSDN says: "It has no effect on the display of the text within the edit control". It is only for the actual buffer used by WM_GETTEXT.
    – Anders
    Jun 27, 2019 at 0:19

2 Answers 2

1

The EditBox does not support toggling word-wrap. There is no message you can send and you cannot change the window style because MSDN says:

After the control has been created, these styles cannot be modified, except as noted.

Your only option is to create a new control with the desired style (WS_HSCROLL|ES_AUTOHSCROLL), copy the text into the new control and then destroy the old control.

On Windows 2000 and later you can use EM_GETHANDLE+EM_SETHANDLE to swap the buffers without having to make a copy of the text.

1

Standard Windows control EDITBOX doesn't support toggling word wrap.

Notepad simulates it by creating new EDITBOX and destroying old one. You could verify this with Spy++. Observe how window handle changes after you toggle word wrap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.