Jump to content

RichEdit / Hanging indentation

Go to solution Solved by HurleyShanabarger,

Recommended Posts

Hi there,

I changedthe status output in one of my script from Edit to RichEdit control and this is really benefical (font formatting, colors, clickable links, etc). One thing that bugs me, is the fact that I can't figure out how create a hanging indentation like in word. If I preformat the stuff in word I am able to copy it into an RichEdit control and the format stays the same:


Can someone point me in the right direction to achieve that using and UDF?

Edited by HurleyShanabarger
Link to post
Share on other sites

I wouldn't now directly as I dont use it frequently but I would take this approach

  1. Copy it from word to your control
  2. Save it as rtf and look at the hanging indent rtf part
  3. Then you can use that rtf part to create your hanging indent
  4. Read the UDF to see how that handles the different rtf constructs

Maybe interesting not directly related but there are different versions around of that dll



Link to post
Share on other sites
  • Solution

Found the solution, _GUICtrlRichEdit_SetParaIndents does the job

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #Tidy_Parameters=/reel /sf /ri
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#Region Includes
    #include <GUIConstantsEx.au3>
    #include <GuiRichEdit.au3>
    #include <String.au3>
    #include <WindowsConstants.au3>
#EndRegion Includes

#Region Main

    Func Main()
        ; Create GUI
        Local $hGui = GUICreate("RichEdit with hanging first line", 400, 400, -1, -1)
        Local $hEdt = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 380, 380, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))

        ; Font and color
        _GUICtrlRichEdit_SetSel($hEdt, 0, -1)
        _GUICtrlRichEdit_SetFont($hEdt, Default, "Courier New")
        _GUICtrlRichEdit_SetBkColor($hEdt, 0xF0F0F0)
        Local $iIndent = 20
        _GUICtrlRichEdit_SetParaIndents($hEdt, $iIndent, 0, -1 * $iIndent)

        ; Append text and reset selection
        Local $sgText = "long line, which will be broken into the next." & _StringRepeat(" The text will be aligned!", 15)
        _GUICtrlRichEdit_AppendText($hEdt, "[13:14:54]" & @TAB & "First " & $sgText)
        _GUICtrlRichEdit_AppendText($hEdt, @CRLF & "[13:14:54]" & @TAB & "Second " & $sgText)
        _GUICtrlRichEdit_AppendText($hEdt, @CRLF & "[13:14:54]" & @TAB & "Third " & $sgText)
        _GUICtrlRichEdit_AppendText($hEdt, @CRLF & "[13:14:54]" & @TAB & "Fourth " & $sgText)
        _GUICtrlRichEdit_SetSel($hEdt, 0, 0, False)

        ; Show GUI

        ; Main loop
        Local $iMsg
        While True
            $iMsg = GUIGetMsg()
                Case $iMsg = $GUI_EVENT_CLOSE
    EndFunc   ;==>Main
#EndRegion Main


Edited by HurleyShanabarger
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...