I know this is an old post but I figured it out after @orbs requested I look at this from another topic. Initially I couldn't figure it out either. I thought the $WS_HSCROLL was word wrap, and it very well may be for a regular edit control, but for richedit there is an actual word wrap option. using EM_SETTARGETDEVICE you can enable/disable word wrap
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
; build GUI
Global Const $nGUI_MaxW = 500, $nGUI_MaxH = 100
Global $nGUI_W = 720, $nGUI_H = 500, $nRichEditOffset = 10, $nRichEditOffsetTop = 30
Global $nToolbarHeight = $nRichEditOffsetTop
Global $hGui = GUICreate('RichEdit wrap/unwrap test', $nGUI_W, $nGUI_H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU))
GUISetBkColor(0xCCDDEE)
; - toolbar ; ** requires an extra lower contour if main rich edit is not docked to edges
Global $gToolbarBackground = GUICtrlCreateLabel('', 0, 0, $nGUI_W, $nToolbarHeight)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT))
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $gToolbarBackgroundContour = GUICtrlCreateLabel('', 0, $nToolbarHeight+1, $nGUI_W, 1)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT))
GUICtrlSetBkColor(-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
; -- wrap/unwrap
Global $bWrap = False
Global $gWrap = GUICtrlCreateCheckbox('Wrap', 3, 3, 48, 24, $BS_PUSHLIKE)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE))
; - main
Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $nGUI_W - $nRichEditOffset * 2, $nGUI_H - $nRichEditOffset * 2 - $nRichEditOffsetTop - 24, BitOR($ES_MULTILINE, $WS_HSCROLL, $WS_VSCROLL))
_GUICtrlRichEdit_SetSel($hRichEdit, 0, -1, True)
_GUICtrlRichEdit_SetFont($hRichEdit, Default, 'Courier New')
GUISetState()
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO")
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
; work with GUI
Global $iMsg = 0
While True
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit)
Exit
Case $gWrap
$bWrap = Not $bWrap
ConsoleWrite(_GUICtrlRichEdit_WordWrap($hRichEdit, $bWrap) & @LF)
EndSwitch
WEnd
Func _GUICtrlRichEdit_WordWrap($hWnd, $bEnable = True)
If (IsHWnd($hWnd) = False) Then Return SetError(1, 0, False)
DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $EM_SETTARGETDEVICE, "wparam", 0, "lparam", Not $bEnable)
If (@Error) Then Return SetError(2, @extended, False)
Return True
EndFunc
This topic gave me the answer.