How do I toggle word-wrap in a EditBox

1.1k views Asked by At

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

There are 2 answers

0
Anders On BEST ANSWER

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.

0
Daniel Sęk On

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.