electrico Posted December 10, 2010 Share Posted December 10, 2010 (edited) Hi everyone. Just one question. As I have searched in forums and found less results than I have been expected, i have a right for next stupid question. _GuiCtrlRichEdit_SetCharColor($hRichEdit, "000587") Please show me where to look for these digits, accordingly, if i want blue color, purple.. etc.. where to get these values? Thanks in advance. elect. P.S. sorry if i missplaced with forum, as it is GUI question. Edited December 10, 2010 by electrico Link to comment Share on other sites More sharing options...
James Posted December 10, 2010 Share Posted December 10, 2010 Hi everyone. Just one question. As I have searched in forums and found less results than I have been expected, i have a right for next stupid question. _GuiCtrlRichEdit_SetCharColor($hRichEdit, "000587") Please show me where to look for these digits, accordingly, if i want blue color, purple.. etc.. where to get these values?Thanks in advance.elect.P.S. sorry if i missplaced with forum, as it is GUI question.RGB. Red Green Blue. Not as hex but just as a string, "FF0000" is red for example. Just look for HTML hex colours and remove the beginning #James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
electrico Posted December 10, 2010 Author Share Posted December 10, 2010 (edited) Ok mister MVP jbrooksuk, thx for quick replay, but here you are => directly from help file. Please help me to get blue text in this example. I haven't succeed. expandcollapse popup #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Color.au3> Opt('MustDeclareVars', 1) Global $lblMsg, $hRichEdit Main() Func Main() Local $hGui, $iMsg, $btnNext, $iStep = 0 $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName,4) & ")", 320, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $lblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60) $btnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30) GUISetState() _GuiCtrlRichEdit_SetText($hRichEdit, "Paragraph 1") While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $iMsg = $btnNext $iStep += 1 Switch $iStep Case 1 Report("1. Initial setting") Case 2 _GuiCtrlRichEdit_SetCharColor($hRichEdit, "ff0000") Report("2. Setting is now") Case 3 _GuiCtrlRichEdit_SetSel($hRichEdit, 1, 5) _GuiCtrlRichEdit_SetCharColor($hRichEdit) Report("3. Background of a few characters changed") Case 4 _GuiCtrlRichEdit_SetSel($hRichEdit, 6, -1) ; Stream all text to the Desktop so you can look at settings in Word _GuiCtrlRichEdit_Deselect($hRichEdit) _GuiCtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf") Report("4. Saved to File") GUICtrlSetState($btnNext, $GUI_DISABLE) EndSwitch EndSelect WEnd EndFunc ;==>Main Func Report($sMsg) Local $iColor = _GUICtrlRichEdit_GetCharColor($hRichEdit) Local $sMixed = _Iif(@extended, "+", "~") Local $aRet = _ColorGetRGB($iColor) $sMsg = $sMsg & @CR & @CR & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " Color=0x" & Hex($iColor) & ":" & $sMixed GUICtrlSetData($lblMsg, $sMsg) ControlFocus($hRichEdit, "", "") EndFunc ;==>Report And thx in advance. Edited December 10, 2010 by electrico Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2010 Moderators Share Posted December 10, 2010 electrico, You might like to look at this function which I wrote to get coloured and sized text into RichEdits: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> $hGui = GUICreate("RichEdit Test", 320, 350) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState() Sleep(2000) ; Increase by 12 pts, set to "bold" and colour red _GUICtrlRichEdit_WriteLine($hRichEdit, "I am the BIG Heading!" & @CRLF, 0xFF0000, +12, "+bo") Sleep(2000) ; Decrease by 6 pts, take away "bold" and colour Green _GUICtrlRichEdit_WriteLine($hRichEdit, "I am the smaller Subheading!" & @CRLF, 0x00FF00, -6, "-bo") Sleep(2000) ; Reduce by the other 6 pts, leave the attibutes alone and colour blue _GUICtrlRichEdit_WriteLine($hRichEdit, "I am normal blue text!" & @CRLF, 0x0000FF, -6, "") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iColor = -1, $iIncrement = 0, $sAttrib = "") ; Count the @CRLFs StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "") Local $iLines = @extended ; Adjust the text char count to account for the @CRLFs Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines ; Add new text _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF) ; Select text between old and new end points _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) ; Convert colour from RGB to BGR $iColor = Hex($iColor, 6) $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2) ; Set colour If $iColor <> -1 Then _GuiCtrlRichEdit_SetCharColor($hWnd, $iColor) ; Set size If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement) ; Set weight If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib) ; Clear selection _GUICtrlRichEdit_Deselect($hWnd) EndFunc I hope it might be of some help to you. 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...
electrico Posted December 10, 2010 Author Share Posted December 10, 2010 Melba, it s very helped me. Thx. Respect jbrooksuk, respect melba. Continue working... Link to comment Share on other sites More sharing options...
James Posted December 10, 2010 Share Posted December 10, 2010 Melba, it s very helped me. Thx. Respect jbrooksuk, respect melba. Continue working...I do apologize, I completely forgot that you must set the selection to affect. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
electrico Posted December 21, 2010 Author Share Posted December 21, 2010 I do apologize, I completely forgot that you must set the selection to affect.Ok jbrooks, if you want, please send me pm about how to operate colors in guirichedit. thx for advance 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