Jump to content

Recommended Posts

Posted (edited)

I need to find a whole line, how to do this?

_GUICtrlRichEdit_FindText($hRichEdit1, $temp, True, False, True)

I tried different options @CR @CRLF for $temp, none of them work.

YKdqbD7.jpg

Edited by mike2003
Posted (edited)

I suggest you read each line one after the other with_GUICtrlRichEdit_GetTextInLine based on the number of lines obtained with _GUICtrlRichEdit_GetLineCount.  If there a match you got your line...

Edit I tested _GUICtrlRichEdit_FindText with @CR and it is working for me.  But the approach I suggested is more robust.

Edited by Nine
Posted (edited)

Let's see your example. I tried this $temp & @CR, and it only works at the end (bottom, last line). And it doesn't work in the middle line.
@CR & $temp It doesn't work at all.

Edited by mike2003
Posted
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>
Global $g_idLblMsg
Example()
Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $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))
    _GUICtrlRichEdit_SetFont($hRichEdit, 15, "Tahoma")
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, "This is a test.")
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "appended text")
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "appended text fjff")

    _GUICtrlRichEdit_SetSel($hRichEdit, 0, 0)
    $aa = _GUICtrlRichEdit_FindText($hRichEdit, "appended text" & @CR, True, False, True)
    _GUICtrlRichEdit_SetSel($hRichEdit, $aa, $aa + 13)
    GUICtrlSetData($g_idLblMsg, $aa)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

I took an example from help, added lines and it doesn't work.

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...