Sign in to follow this  
Followers 0
PvS1

How to force scrolling of listbox?

5 posts in this topic

Hi,

I am a happy user of autoIT. I created a program that uses a logging window. I used:

create: GUICreate()

add line: GUICtrlSetData()

This works OK, once the window is full a scrolbar appears and lines are added.

I experience 1 problem: Once the window is full and the scrolbar appears I no longer see the latest logging. To see the latest logging I need to manipulate the scrolbar with my mouse manually.

What do I need to do to cause the most recently sent logging line to show automatically?

Kind regards,

PvS1

Share this post


Link to post
Share on other sites



This Should help LINK

Please give the full code


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

PvS1,

Welcome to the AutoIt forum. :)

This should show you the method to use: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>

$hGUI = GUICreate("Test", 320, 500)
$hList = GUICtrlCreateList("", 10, 10, 310, 150)
GUISetState(@SW_SHOW)

GUICtrlSetData($hList, "1st message timed at " & @MIN & ":" & @SEC)

; Start a timer to simulate messages arriving
$iBegin = TimerInit()

;Loop to keep GUI polling
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Every second
    If TimerDiff($iBegin) > 1000 Then
        GUICtrlSetData($hList, "New message timed at " & @MIN & ":" & @SEC)
        ;Scroll the list control
        GUICtrlSendMsg($hList, $WM_VSCROLL, $SB_LINEDOWN, 0)
        ; Reset the timer
        $iBegin = TimerInit()
    EndIf

WEnd

Please ask if you have any questions. :)

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

Mine modification of Melba's one:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>
#include <GUIListBox.au3>

$hGUI = GUICreate("Test", 320, 500)
$hList = GUICtrlCreateList("", 10, 10, 310, 150, BitOR($LBS_NOTIFY,$LBS_NOSEL,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER))
GUISetState(@SW_SHOW)

Logging("1st message timed at " & @MIN & ":" & @SEC)

; Start a timer to simulate messages arriving
$iBegin = TimerInit()

;Loop to keep GUI polling
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Every second
    If TimerDiff($iBegin) > 1000 Then
        Logging("New message timed at " & @MIN & ":" & @SEC)
        ; Reset the timer
        $iBegin = TimerInit()
    EndIf

WEnd

Func Logging($text)
    _GUICtrlListBox_BeginUpdate($hList)
    $index = _GUICtrlListBox_AddString($hList, $text)
    _GUICtrlListBox_SetTopIndex($hList, $index)
    _GUICtrlListBox_UpdateHScroll($hList) ; to correct size of horiz scrollbar for texts with big width
    _GUICtrlListBox_EndUpdate($hList)
EndFunc

Share this post


Link to post
Share on other sites

Thanks for the help, problem solved

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  
Followers 0