orbs Posted February 18, 2015 Share Posted February 18, 2015 (edited) when the RichEdit is created with style $WS_HSCROLL, the text is not wrapped and there is an horizontal scrollbar. the opposite is also true: when the RichEdit is created without style $WS_HSCROLL, the text is wrapped, and there is no horizontal scrollbar. so far so good. now i want to toggle wrap/unwrap. i tried doing it by changing the style of the RichEdit with this: _WinAPI_SetWindowLong($hRichEdit, $GWL_STYLE, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) (the style used by _GUICtrlRichEdit_Create is the same, but with $WS_HSCROLL). this does not work - or perhaps it does work, but i don;t see it, because it makes the entire RichEdit disappear. where am i going wrong? this is the full demo script: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #NoTrayIcon #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, 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' & @LF, $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $nGUI_W - $nRichEditOffset * 2, $nGUI_H - $nRichEditOffset * 2 - $nRichEditOffsetTop - 24, BitOR($ES_MULTILINE, $ES_READONLY, $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 If $bWrap Then _WinAPI_SetWindowLong($hRichEdit, $GWL_STYLE, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) Else _WinAPI_SetWindowLong($hRichEdit, $GWL_STYLE, BitOR($ES_MULTILINE, $ES_READONLY, $WS_HSCROLL, $WS_VSCROLL)) EndIf EndSwitch WEnd #region resizing funcs Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $tagMaxinfo If $hWnd = $hGui Then $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $nGUI_MaxW) ; min X DllStructSetData($tagMaxinfo, 8, $nGUI_MaxH) ; min Y Return 0 EndIf EndFunc ;==>_WM_GETMINMAXINFO Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ; ref: http://www.autoitscript.com/forum/topic/123904-solved-auto-resizing-richedit-control/#entry860464 If $hWnd = $hGui Then Local $iWidth = _WinAPI_LoWord($lParam) ; the entire GUI internal width Local $iHeight = _WinAPI_HiWord($lParam) ; the entire GUI internal height _WinAPI_MoveWindow($hRichEdit, $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $iWidth - $nRichEditOffset * 2, $iHeight - $nRichEditOffset * 2 - $nRichEditOffsetTop) EndIf EndFunc ;==>_WM_SIZE #endregion resizing funcs thanks for any hints. EDIT: there is the possibility of destroying and re-creating the RichEdit: '?do=embed' frameborder='0' data-embedContent>> i'll try it unless i can find something less brutal. Edited February 18, 2015 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2015 Moderators Share Posted March 2, 2015 orbs,Like you, the only way I can get this to work is by destroying and recreating the RichEdit: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GuiRichEdit.au3> Global $bWrap = False $sText = "A very very long line that needs to wrap in the RuchEdit and so is useful in the context of this example" For $i = 1 To 3 $sText &= @CRLF & $sText Next ; build GUI Global Const $nGUI_MaxW = 500, $nGUI_MaxH = 100 Global $nGUI_W = 720, $nGUI_H = 500, $nRichEditOffset = 10, $nRichEditOffsetTop = 30 Global $hGui = GUICreate('RichEdit wrap/unwrap test', $nGUI_W, $nGUI_H) GUISetBkColor(0xCCDDEE) ; -- wrap/unwrap Global $cWrap = GUICtrlCreateCheckbox('Wrap', 3, 3, 48, 24, $BS_PUSHLIKE) ; - main Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, $sText, $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $nGUI_W - $nRichEditOffset * 2, $nGUI_H - $nRichEditOffset * 2 - $nRichEditOffsetTop - 24, BitOR($ES_MULTILINE, $ES_READONLY, $WS_HSCROLL, $WS_VSCROLL)) _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1, True) _GUICtrlRichEdit_SetFont($hRichEdit, Default, 'Courier New') GUISetState() ; work with GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $cWrap ; Store current stream Local $bStream = _GUICtrlRichEdit_StreamToVar($hRichEdit) ; Empty RichEdit _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) _GUICtrlRichEdit_ReplaceText($hRichEdit, "") ; Toggle wrap $bWrap = Not $bWrap ; Destroy and recreate RichEdit with the necessary styles _GUICtrlRichEdit_Destroy($hRichEdit) If $bWrap Then $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $nGUI_W - $nRichEditOffset * 2, $nGUI_H - $nRichEditOffset * 2 - $nRichEditOffsetTop - 24, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) Else $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $nGUI_W - $nRichEditOffset * 2, $nGUI_H - $nRichEditOffset * 2 - $nRichEditOffsetTop - 24, BitOR($ES_MULTILINE, $ES_READONLY, $WS_HSCROLL, $WS_VSCROLL)) EndIf ; Reload the stream _GUICtrlRichEdit_StreamFromVar($hRichEdit, $bStream) EndSwitch WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
InunoTaishou Posted January 19, 2017 Share Posted January 19, 2017 (edited) 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 expandcollapse popup#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. Edited January 19, 2017 by InunoTaishou mLipok, pixelsearch, orbs and 1 other 4 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2017 Moderators Share Posted January 19, 2017 InunoTaishou, Good job! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
InunoTaishou Posted January 19, 2017 Share Posted January 19, 2017 Maybe a future UDF added to the GUIRichEdit.au3 Link to comment Share on other sites More sharing options...
orbs Posted January 28, 2017 Author Share Posted January 28, 2017 @InunoTaishou, thank you so much for this. have you any idea how to get the wrap status of a RichEdit control? i recon if the UDF _GUICtrlRichEdit_SetWrap() is to be created, it would probably need to be accompanied by _GUICtrlRichEdit_GetWrap(). not that i mind so much, since i control the wrap status; but just in case... i looked at _GUICtrlRichEdit_GetParaAttributes() and _GUICtrlRichEdit_GetParaAlignment() but they don't provide it. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
InunoTaishou Posted January 28, 2017 Share Posted January 28, 2017 I can give it a go when I got some free time. Just some quick googling you're not going to find what you want with any of the autoit richedit functions https://msdn.microsoft.com/en-us/library/aa313357(v=vs.60).aspx SetTargetDevice works with the dc of the richedit controls, setting the line width of the WYSIWYG formatting. So, we'll have to figure out how to get the current WYSIWYG options and check the line width. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now