Jump to content

Question about Listbox Styles in a GUI


Recommended Posts

Im working on a small script that makes *.m3u (playlist) files and I have a GUI that contains a Listbox.

My problem is if a file has a very large directory (larger than the set size of the listbox), a scroll bar doesn't appear in the same way

it would in the vertical direction. I looked through the styles and didn't see anything about a Horizontal scroll bar.

This is what I have tried so far.

$guictrl[1] = GUICtrlCreateList("", 60, 10, 630, 210, $LBS_SORT = 0 & $WS_HSCROLL = 1)

I am not very familiar with using GUI styles so the line above is probably incorrect.

While $i < $arraypos
        GUICtrlSetData($guictrl[1], $files[$i])
        $strlen = StringLen($files[$i])
        If $strlen > 88 Then
            $horiz_fit = Round($strlen * 7.08)
        EndIf
        $i += 1
    WEnd
    
    _GUICtrlListBox_SetHorizontalExtent($guictrl[1], $horiz_fit)

I could be using _GUICtrlListBox_SetHorizontalExtent() incorrectly I am not sure, but I know I am missing somthing.

Any help is greatly appreciated.

Edited by ragnarok775
Link to comment
Share on other sites

I figured I was doing something wrong on that line, the problem now is $LB_SORT is turned on by default

by putting $LB_SORT = 0 i was able to turn it off but that is probably not the correct way of doing so.

So the reason $WS_HSCROLL wasn't working was because i messed up all the values by changing $LB_SORT to 0.

How would I go about turning $LB_SORT off and $WS_HSCROLL on in the same line?

Link to comment
Share on other sites

I figured I was doing something wrong on that line, the problem now is $LB_SORT is turned on by default

by putting $LB_SORT = 0 i was able to turn it off but that is probably not the correct way of doing so.

So the reason $WS_HSCROLL wasn't working was because i messed up all the values by changing $LB_SORT to 0.

How would I go about turning $LB_SORT off and $WS_HSCROLL on in the same line?

You don't turn something off, only the styles that is defined will be used so simply omit $LB_SORT

$guictrl[1] = GUICtrlCreateList("", 60, 10, 630, 210, $WS_HSCROLL)
Link to comment
Share on other sites

That is the problem, $LB_SORT (sorts everything in the list box by alphanumeric order) is on by default. I cannot make it

properly display the items in the files[] array in the order that they are.

Ex. Say I have the following array:

$file[0] = "ZEBRA"
$file[1] = "APPLE"
$file[2] = "DOG
"

If I use

$guictrl[1] = GUICtrlCreateList("", 60, 10, 630, 210, $WS_HSCROLL)

When I load the array into the Listbox, it displays

APPLE
DOG
ZEBRA

But when I added in the $LB_SORT = 0 it showed the files in the same order as the array, which is what I want.

EDIT: OK, after playing with GUICtrlSetStyle and other things... Completely out of the blue, the listbox stopped putting things in

alphanumeric order.

But anyway, the Listbox is working properly now.

Thank You AdmiralAlkex & Josbe for taking the time to read my post and help out.

Edited by ragnarok775
Link to comment
Share on other sites

You are wrong, they are not sorted at all

#include <WindowsConstants.au3>

GUICreate("test")
$List = GUICtrlCreateList("", 0, 0, "", "", $WS_HSCROLL)

GUISetState()

GUICtrlSetData($List, "ZEBRA|APPLE|DOG")

While 1
    Sleep(10)
WEnd
Link to comment
Share on other sites

You are wrong, they are not sorted at all

#include <WindowsConstants.au3>

GUICreate("test")
$List = GUICtrlCreateList("", 0, 0, "", "", $WS_HSCROLL)

GUISetState()

GUICtrlSetData($List, "ZEBRA|APPLE|DOG")

While 1
    Sleep(10)
WEnd
Call me a liar if you wish but I know what I saw and it caused me problems with a couple of my functions for like an hour last night

to the point where I just stopped trying and went to sleep.

A bug maybe? I don't know, but all last night I could not figure out why when

I called my Swap function, basically switched $files[$i] data with $files[$i + 1], and then used _ArrayDisplay[$files]... the Display

showed that my function worked fine but the Listbox would always put them in a different order.

EDIT: OK, I just found out what the problem was, and maybe I just don't know how Styles work but here is what happens

If I use

$guictrl[1] = GUICtrlCreateList("", 60, 10, 630, 210,  $WS_HSCROLL)

The listbox does not Sort itself in Alphanumric order.... BUT if you use

$guictrl[1] = GUICtrlCreateList("", 60, 10, 630, 210)

Which is what I was doing ALL last night (I didn't need the horizontal scroll bar yet). Then IT WILL SORT the values.

Edited by ragnarok775
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...