Jump to content

_GUICtrlEdit_SetText and how it handles @CRLF and @CR differently


Go to solution Solved by Andreik,

Recommended Posts

Posted

Is there a setting for interpreting @CR as @CRLF ?  Perhaps in a GUICtrlCreateEdit style option? or maybe option for _SetText or _AppendText?

I ask because if you run the program you see _GUICtrlEdit_SetText and _GUICtrlEdit_GetText handle them differently.  _GUICtrlEdit_GetText always treats it a @CRLF

I guess I could always preprocess @CR, @LF, and @LFCR into @CRLF before using _SetText or _AppendText

Thanks for any hints,

ahha

_GUICtrlEdit_SetText question.au3

  • Solution
Posted

Don't be tricked by what you see, everything works as expected, you get exactly what you set (convert the string returned by _GUICtrlEdit_GetText() to binary if you want to be sure). If you want a different end of line character and you have at least Win 10 then look at EM_GETENDOFLINE and EM_SETENDOFLINE.

Posted (edited)
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()    ;modified from _GUICtrlEdit_SetText example

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Set Text", 400, 300)
    GUISetFont(11, 400, 0, "Courier New")
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    Local $sTxt = ""
    $sTxt &= "A @CRLF test" & @CRLF & "After @CRLF" & @CRLF
    $sTxt &= "A @CR test" & @CR & "After @CR test" & @CRLF
    $sTxt &= "A @LF test" & @LF & "After @LF test" & @CRLF
    $sTxt &= "~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF

    _GUICtrlEdit_SetText($idEdit, $sTxt)
    ConsoleWrite("$sTxt=" & $sTxt & @CRLF)
    ConsoleWrite("****************************" & @CRLF)

    MsgBox($MB_SYSTEMMODAL, "Information 1", $sTxt)

    _GUICtrlEdit_AppendText($idEdit, @CRLF)
    _GUICtrlEdit_AppendText($idEdit, _GUICtrlEdit_GetText($idEdit))
    ConsoleWrite(_GUICtrlEdit_GetText($idEdit))
    MsgBox($MB_SYSTEMMODAL, "Information 2", _GUICtrlEdit_GetText($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

https://www.autoitscript.com/forum/topic/150872-how-to-post-code-on-the-forum/

 

Edited by ioa747

I know that I know nothing

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