Jump to content

Edit Control - Set Focus to Bottom


Gestalt
 Share

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?

Link to comment
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)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $i = 1 To 40
                _EditScrollUp("Example Line "&$i&@CRLF)
                Sleep(200)
            Next
    EndSwitch
WEnd

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

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 :)

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