Sign in to follow this  
Followers 0
kor

can a listbox be set to auto scroll?

4 posts in this topic

#1 ·  Posted (edited)

#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>


Global $hListBox
Global $var

    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Create Staff Progress", 400, 296)
    $hListBox = _GUICtrlListBox_Create($hGUI, "", 2, 2, 396, 296, BitOR($LBS_NOSEL, $WS_VSCROLL))
    GUISetState()

    ;MsgBox(4160, "Information", "Creating Staff")

    ; Add files
    ;_GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)

    $num = 0
    Do
        $num = $num + 1
        _GUICtrlListBox_InsertString($hListBox, $num, -1)
        Sleep(100)
    Until $num > 30

    ;_GUICtrlListBox_EndUpdate($hListBox)
    
    Sleep(1200)
    $var = False

    ; Loop until user exits
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE Or $var = False

Is there a way to make this listbox auto scroll such that the newest number is always at the bottom, but you don't have to manually scroll? As the numbers populate, the listbox is automatically trying to scroll down so you always see the newest number?

I realize I can change the InsertString from a -1 to 0 to have the numbers count upward with the highest number always being at the top, but I'm not a fan of that approach.

EDIT: I'm also having a problem such that while the numbers are counting, it I attempt to close the GUI it will not close until the numbers have finished. Any idea why that is?

Edited by kor

Share this post


Link to post
Share on other sites



kor,

Hi again! :D

Is there a way to make this listbox auto scroll such that the newest number is always at the bottom

Send the list a message asking it to scroll to the end. :)

if I attempt to close the GUI it will not close until the numbers have finished

Because until the numbers have finished you never look for an event via GUIGetMsg - you need to check as the numbers are being inserted. :P

Here is an amended Do...Until loop:

Do
    $num = $num + 1
    _GUICtrlListBox_InsertString($hListBox, $num, -1)
    ; Scroll to bottom of list
    $iCount = _SendMessage($hListBox, 0x18B, 0, 0) ; $LB_GETCOUNT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    _SendMessage($hListBox, 0x197, $iCount - 1, 0) ; $LB_SETTOPINDEX <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Sleep(100)
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit ; Look for the [X] being clicked <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Until $num > 30

Please ask if anything is unclear. :)

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

I can take from that code what you are doing and figure the rest out. Thank you!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi kor,

here another way to scroll do actual insertet String:

Do
        $num = $num + 1
        _GUICtrlListBox_InsertString($hListBox, $num, -1)
        _GUICtrlListBox_SetCurSel($hListBox, $num -1)
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
        Sleep(100)
Until $num > 30

mfg autoBert

Edited by AutoBert

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