Fran Posted November 3, 2010 Share Posted November 3, 2010 I've tried various examples of richedit and none of them do anything. I want to create an Edit box with the Heading big and bold another sub-head smaller, but still bold and the rest of the text normal. I am yet to find an example that actually works on my machine. Maybe it's just a setting somewhere? Can anyone please assist? F Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2010 Moderators Share Posted November 3, 2010 Fran,Like you, I find RichEdit controls quite difficult to deal with. I wrote this little function a while ago to help me out - I hope you find it useful: 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, +12, "+bo", 0xFF0000) Sleep(2000) ; Decrease by 6 pts, take away "bold" and colour Green _GUICtrlRichEdit_WriteLine($hRichEdit, "I am the smaller Subheading!" & @CRLF, -6, "-bo", 0x00FF00) Sleep(2000) ; Reduce by the other 6 pts, leave the attibutes alone and colour black _GUICtrlRichEdit_WriteLine($hRichEdit, "I am normal text!" & @CRLF, -6, "", 0x000000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd 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) EndFuncAs you can see, you have to amend the size and attibutes of the text relative to the previous insertion - not what we are used to, so be careful here. All clear? M23 SupaNewb 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...
Fran Posted November 3, 2010 Author Share Posted November 3, 2010 As always! - thank you thank you thank you!! Link to comment Share on other sites More sharing options...
Fran Posted November 3, 2010 Author Share Posted November 3, 2010 Just one small problem... I can't hide the edit box with GUICtrlSetState() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2010 Moderators Share Posted November 3, 2010 Fran,As the RichEdit is not a native Autoit control, the GUICtrl* commands will not work on it. You have to use WinSetState on it: WinSetState($hRichEdit, "", @SW_HIDE) Sleep(2000) WinSetState($hRichEdit, "", @SW_SHOW)M23P.S. Can I go and look at your other topic now or do we still have business 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...
Fran Posted November 3, 2010 Author Share Posted November 3, 2010 we're done here Link to comment Share on other sites More sharing options...
Luigi Posted September 5, 2011 Share Posted September 5, 2011 Hi Melba, If I understand correctly, you script above count all lines alread printed and put the cursor after the last line printed, not re-printing everything from _GUICtrlRichEdit_Create? _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) Thanks ^^ Visit my repository Link to comment Share on other sites More sharing options...
Chad2 Posted January 31, 2012 Share Posted January 31, 2012 This helped me. Thanks Melba! 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