TheDcoder Posted March 2, 2015 Share Posted March 2, 2015 Hello, Today I have a new question about edit box control, please look at the image below: I want the colors as specified for each event.... Code for the edit box: $output_terminal = GUICtrlCreateEdit("[INFO] Welcome to the Developer Console" & @CRLF,0,285,546,124,2048,-1) Code for the function which is used by the whole program: Func SendEvent($type, $msg) If $type = 0 Then $type = '[OKAY] ' If $type = 1 Then $type = '[EROR] ' If $type = 2 Then $type = '[WARN] ' If $type = 3 Then $type = '[INFO] ' GUICtrlSetData($output_terminal, $type & $msg & @CRLF, 1) EndFunc Thanks in advance EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2015 Moderators Share Posted March 2, 2015 TheDcoder,If you want different colours for each line type then you will need a RichEdit control. Or you can use multiple labels and scroll. Here is an example script showing how you can do this - you need my Scrollbars UDF: #include <GUIConstantsEx.au3> #Include <GuiScrollBars_Ex.au3> Global $iLines = 50 ; Number of items in GUI ; Create GUI $hGUI = GUICreate("Scroll Colour Line List", 400, 400) ; Create "list" with coloured lines For $i = 0 To $iLines - 1 GUICtrlCreateLabel("This is line " & $i, 10, 10 + ($i * 20), 380, 20) GUICtrlSetColor(-1, Random(0, 0xFFFFFF, 1)) Next GUISetState() ; Generate scrollbars _GUIScrollbars_Generate($hGui, 0, 4 + ($iLines * 20)) ; Just this one line is all you need to get scrollbars !!!!!!!!!!!!!!!!!!!!!!!!!! While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit 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...
TheDcoder Posted March 2, 2015 Author Share Posted March 2, 2015 @Melba23 Can you give me a example for Rich Edit Box too ? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2015 Moderators Share Posted March 2, 2015 TheDcoder,Feeling lazy today? Go look at the RichEdit examples in the Help file and come back if you have problems. M23P.S. Or you could look >here. 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...
TheDcoder Posted March 2, 2015 Author Share Posted March 2, 2015 Let me say it again, You are the best Melba!!!! EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted March 2, 2015 Author Share Posted March 2, 2015 There is a small glitch in your _GUICtrlRichEdit_WriteLine Function, It does not accept @CRLF here is my line of code: _GUICtrlRichEdit_WriteLine($output_terminal, $type & $msg & @CRLF, 0, "", $colour) EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2015 Moderators Share Posted March 2, 2015 TheDcoder, It does not accept @CRLFSeeing as the example script to which I linked uses @CRLF in every call to the function without any difficulty, I find that a little hard to believe. 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...
TheDcoder Posted March 2, 2015 Author Share Posted March 2, 2015 (edited) @Melba23 My GUICreateOutputTerminal function: (Used to create Terminal) Func GUICreateOutputTerminal() $return = _GUICtrlRichEdit_Create($main_GUI, "", 0, 285, 546, 124, $ES_READONLY) _GUICtrlRichEdit_SetFont($return, Default, "Consolas") Local $RGB[3] $RGB[0] = 0 $RGB[1] = 0 $RGB[2] = 0 $colour = _ColorSetCOLORREF($RGB) _GUICtrlRichEdit_SetBkColor($return, $colour) Return $return EndFunc ;= OutputTerminal My SendEvent funtion: (Used to send events with ease) Func SendEvent($type, $msg) Local $colour If $type = 0 Then $type = '[OKAY] ' $colour = 0x00FF000 ElseIf $type = 1 Then $type = '[EROR] ' $colour = 0xFF0000 ElseIf $type = 2 Then $type = '[WARN] ' $colour = 0xFFFF00 ElseIf $type = 3 Then $type = '[INFO] ' $colour = 0x4545FF EndIf _GUICtrlRichEdit_WriteLine($output_terminal, $type & $msg & @CRLF, 0, "", $colour) EndFunc ;= SendEvent Your _GUICtrlRichEdit_WriteLine function: (Your function) Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1) ; 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 What do you think is wrong ? Edited March 3, 2015 by TheDcoder EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2015 Moderators Share Posted March 2, 2015 TheDcoder, What do you think is wrong >No idea from those snippets - I have no idea how they all fit together as neither of the first two appear to have any relationship to each other. Post the whole script and I might be able to offer an suggestion. 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...
TheDcoder Posted March 3, 2015 Author Share Posted March 3, 2015 I have no idea how they all fit together as neither of the first two appear to have any relationship to each other. The first one is my function to send events to the terminal & the second is to create the terminal Can I PM you the whole script? b/c I don't want others who are using my software can get the source code.. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2015 Moderators Share Posted March 3, 2015 TheDcoder,By all means PM me the script. 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...
Moderators Melba23 Posted March 3, 2015 Moderators Share Posted March 3, 2015 TheDcoder,That was easy - you need to add the $ES_MULTILINE style to your RichEdit control so that it recognises @CRLF. 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...
TheDcoder Posted March 3, 2015 Author Share Posted March 3, 2015 That was easy - you need to add the $ES_MULTILINE style to your RichEdit control so that it recognises @CRLF. Thanks , but why did you not recognize the error by looking at the code for GUICreateOutputTerminal function EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2015 Moderators Share Posted March 3, 2015 TheDcoder,In a perfect world I might well have done so - but I did not. Besides, I find it much easier to deal with whole scripts so that I can run them and see what happens - that way I can adjust things as I go along to confirm that I am on the right track (or not!). Debugging is an art, not an exact science, and I prefer seeing the whole picture. M23 TheDcoder 1 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...
TheDcoder Posted March 3, 2015 Author Share Posted March 3, 2015 Now after adding $ES_MULTILINE, its adding an extra @CRLF for me.... (Fixed this by removing @CRLF in the SendEvent function) EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted March 3, 2015 Author Share Posted March 3, 2015 Before: After: EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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