Jump to content

can a listbox be set to auto scroll?


kor
 Share

Recommended Posts

#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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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