Jump to content
Sign in to follow this  

Edit Control - Set Focus to Bottom

Recommended Posts

How can I have the edit control automatically scroll to the very bottom of the control when the script is opened? I have tried doing a ControlSend("^{END}") but that doesn't work. I have looked at GUICtrlSendMsg and I didn't see anything that would help. Is this possible?

Share this post

Link to post
Share on other sites

- get the length of the text in the edit box

- set selection from last character - to - last character

- replace selection with new content

That way it will scroll "up".

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 373, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 16, 16, 593, 305)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Test Me", 272, 336, 75, 25, $WS_GROUP)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $Button1
            For $i = 1 To 40
                _EditScrollUp("Example Line "&$i&@CRLF)

Func _EditScrollUp($content)
    Local $Ed_length = StringLen(GUICtrlRead($Edit1))
    _GUICtrlEdit_SetSel($Edit1, $Ed_length, $Ed_length)
    _GUICtrlEdit_ReplaceSel($Edit1, $content)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post

Link to post
Share on other sites

Thank you for the code, enaiman. I am at home and only have Linux computers but I will try it when I get back to work.

I appreciate your help.

Share this post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...