Sign in to follow this  
Followers 0
pietrog

Help with GUICtrlCreateList

7 posts in this topic

Is there a listbox style that will always display the last item added to the list by default?

When I run the following code, the scroll bar appears after I add more items to the list than the listbox can display. As I continue to add items, the scroll bar slider shrinks but the listbox continues to display the same items as before.

I'd like to have the listbox display the new items I add as I add them to the list instead.

Thanks for any input

#include <GuiConstants.au3>

GUICreate('ListBox')

$mylist = GUICtrlCreateList('', 50, 50, 300, 300)

GUISetState()

For $i = 1 To 100

Sleep(100)

GUICtrlSetData($mylist, $i & '|')

Next

Sleep(10000)

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>
GUICreate('ListBox')
$mylist = GUICtrlCreateList('', 50, 50, 300, 300)
GUISetState()

For $i = 100 To 200
Sleep(100)
GUICtrlSetData($mylist, $i & '|')
Next

Sleep(10000)
This example. They remain in order, as you always have 3 digits.

Does this help? I do not know of a style?

Share this post


Link to post
Share on other sites

Thanks, I changed my code to yours - but my problem is that when the value '121' is displayed at the bottom of the listbox the scrollbar slider starts to shrink instead of displaying '122' etc. at the bottom of the window. So, I'm left with grabing the slider and manually scrolling down to see the values as they are entered into the list. I was hoping it was possible to have it display the new items in the listbox window as they are added without using the scrollbar slider to display them.

Share this post


Link to post
Share on other sites

Try calling the following:

; scrolls list box contents so that either the item appears at top of list or maximum scroll range reached
Func _GuiLB_SetTopIndex($ref, $index)
    Return GuiSendMsg($ref, 0x197, $index, 0);LB_SETTOPINDEX
EndFunc

function:http://www.autoitscript.com/fileman/users/public/CyberSlug/lb_wrappers_self-contained.au3


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Here's a working example. _GuiLB_SetTopIndex does not like it if $index is out of bounds.... I guess I could change that, but the following works:

GUICreate('Example')
$mylist = GUICtrlCreateList('', 50, 50, 300, 300)
GUISetState()

For $i = 100 To 200
   Sleep(50)
   _GuiLB_AddString($mylist, STring($i))
   _GuiLB_SetTopIndex( $myList, _GuiLB_GetCount($myList)-1 )
Next

sleep(10000)
Exit

; scrolls list box contents so that either the item appears at top of list or maximum scroll range reached
Func _GuiLB_SetTopIndex($ref, $index)
    Return GuiSendMsg($ref, 0x197, $index, 0);LB_SETTOPINDEX
EndFunc
 
Func _GuiLB_AddString($ref, $string)
    Return GuiSendMsg($ref, 0x0180, 0, $string);LB_ADDSTRING
 EndFunc
 
 Func _GuiLB_GetCount($ref)
    Return GuiSendMsg($ref, 0x018B, 0, 0);LB_GETCOUNT
 EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Awesome! That's what I was looking for. Now All I have to do is spend some time digesting the code.

Thanks All

Share this post


Link to post
Share on other sites

function:http://www.autoitscript.com/fileman/users/public/CyberSlug/lb_wrappers_self-contained.au3

<{POST_SNAPBACK}>

Talking about wrappers...

@CyberSlug: You has made an excellent work with this(wrappers),

I saw this one in your project (AutoBuilder 27 Nov. Proto). Thxs :idiot:

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