Search the Community
Showing results for tags 'colorize'.
-
I found this example by zedna, it worked perfectly (entering text into the control with specified color), that is until you add any form of line break (@CR, @LF or @CRLF). If the line breaks aren't there, the text entered is colored correctly, but when they are, the colors gets off and I can't figure out why, anyone know what's the matter? #include <GUIConstants.au3> #include <GuiRichEdit.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 448, 269, 192, 124) $Edit1 = _GUICtrlRichEdit_Create($Form1,"", 16, 24, 417, 225) GUISetState(@SW_SHOW) _GUICtrlRichEdit_AppendTextColor($Edit1, "Hello "& @CR, "0x00FF00") _GUICtrlRichEdit_AppendTextColor($Edit1, "Autoit "& @CR, "0xFF0000") _GUICtrlRichEdit_AppendTextColor($Edit1, "World", "0x000000") ;~ _GUICtrlRichEdit_AppendText($Edit1, "World") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($Edit1) Exit EndSwitch WEnd Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) Local $iLength = Int(_GUICtrlRichEdit_GetTextLength($hWnd)/2) ; RichEdit stores text as 2 Byte Unicode chars _GUICtrlRichEdit_AppendText($hWnd, $sText) _GUICtrlRichEdit_SetSel($hWnd, $iLength, $iLength + StringLen($sText)*2) ; position in 2 Byte "Unicode" _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) _GuiCtrlRichEdit_Deselect($hWnd) EndFunc