Jump to content

[append] write text always to the end of edit box


Recommended Posts

Hi there,

I have been looking this for a while, the text inside edit boxes can be massed when the user points the mouse in one of the lines or selecting part of lines inside the edit box.

this behavior can cause massing the entire text sorted in the edit box which is really annoying.

I have been looking for a solution and fortunately there's already workaround solution written by @Melba23

Original link is here:

 

I would like to highlight this issue here in case somebody needed this in the feature :).

Here's an very easy example so you guys can compare:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 373, 344, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 16, 16, 337, 257, $ES_READONLY)
$Button1 = GUICtrlCreateButton("Normal", 48, 296, 75, 25)
$Button2 = GUICtrlCreateButton("Append", 248, 296, 75, 25)
GUICtrlSetData($Edit1, 'Try selecting part of this text' & @CRLF & 'before you click on the buttons !' & @CRLF, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$SomeText = @CRLF & 'This is an example'


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Edit1, $SomeText, 0)
        Case $Button2
            AppendEditBox()
            GUICtrlSetData($Edit1, $SomeText, 0)
    EndSwitch
WEnd


Func AppendEditBox()
    ; source: https://www.autoitscript.com/forum/index.php?showtopic=110948
    Local $iEnd = StringLen(GUICtrlRead($Edit1))
    _GUICtrlEdit_SetSel($Edit1, $iEnd, $iEnd)
    _GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET)
EndFunc   ;==>AppendEditBox

 

I hope that helps somebody.

Thanks!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...