Jump to content
Sign in to follow this  
Rogue5099

Edit box to the top

Recommended Posts

Rogue5099

I am loading  several lines of data into an edit box before I even show a GUI and would like to know if I could have it show the top of the vertical scroll instead of displaying the last bottom.

I have made a quick test GUI to create data and then input it into the edit box.

#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
$HardwareGUI = GUICreate("Test", 300, 305, -1, -1, BitOR($WS_BORDER, $WS_SYSMENU), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
Local $AboutEditbox = GUICtrlCreateEdit("", 0, 0, 295, 255, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_READONLY));, $ES_AUTOVSCROLL
Local $ButtonLink = GUICtrlCreateButton("Google", 0, 255, 300, 25)
Local $Text = ""
$Link = "www.google.com"
GUISetState(@SW_SHOW, $HardwareGUI)
GUICtrlSetState($AboutEditbox, @SW_DISABLE)

For $i = 1 To 60
    $Text &= "Line " & $i & @CRLF
Next

GUICtrlSetData($AboutEditbox, $Text, 1)

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $HardwareGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $ButtonLink
                    ShellExecute($Link)
            EndSwitch
    EndSwitch
WEnd

I would like to show Line 1 when the GUI is shown instead of having to scroll up every time.

Share this post


Link to post
Share on other sites
Melba23

Rogue5099,

Set the caret position and then scroll to it: ;)

#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

$HardwareGUI = GUICreate("Test", 300, 305, -1, -1, BitOR($WS_BORDER, $WS_SYSMENU), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
Local $AboutEditbox = GUICtrlCreateEdit("", 0, 0, 295, 255, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_READONLY));, $ES_AUTOVSCROLL
Local $ButtonLink = GUICtrlCreateButton("Google", 0, 255, 300, 25)
Local $Text = ""
$Link = "www.google.com"
GUISetState(@SW_SHOW, $HardwareGUI)
GUICtrlSetState($AboutEditbox, @SW_DISABLE)

For $i = 1 To 60
    $Text &= "Line " & $i & @CRLF
Next

GUICtrlSetData($AboutEditbox, $Text, 1)
_GUICtrlEdit_SetSel($AboutEditbox, 0, 0)              ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
_GUICtrlEdit_Scroll($AboutEditbox, $SB_SCROLLCARET)   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $HardwareGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $ButtonLink
                    ShellExecute($Link)
            EndSwitch
    EndSwitch
WEnd
All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Rogue5099

Yes but I also found this and was about to post.

#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
$HardwareGUI = GUICreate("Test", 300, 305, -1, -1, BitOR($WS_BORDER, $WS_SYSMENU), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
Local $AboutEditbox = GUICtrlCreateEdit("", 0, 0, 295, 255, BitOR($WS_VSCROLL, $ES_READONLY))
Local $ButtonLink = GUICtrlCreateButton("Google", 0, 255, 300, 25)
Local $Text = ""
$Link = "www.google.com"
GUISetState(@SW_SHOW, $HardwareGUI)

For $i = 1 To 60
    $Text &= "Line " & $i & @CRLF
Next

_GUICtrlEdit_SetText($AboutEditbox, $Text)

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $HardwareGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $ButtonLink
                    ShellExecute($Link)
            EndSwitch
    EndSwitch
WEnd

Thank you for your help though!!

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  

×