Sign in to follow this  
Followers 0
N30N3M3S1S

Horizontal Scroll bar in GUICtrlCreateList

5 posts in this topic

I'm still n00b at this, so bear with me, I'm learning. I'm attempting to make a MP3 player (to practice with file handling and GUI creation). So far every thing works, but I can't seem to get the list box to have a horizontal scroll bar. Vertical scroll bar works, but for the lines that are longer than the list box, they get cut off for I can't seem to figure out how to make a horizontal scroll bar on this control. I've tried different styles, but still nothing...

Here is what I have so far;

#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>

;loading lists and other crap
$file = FileOpen("playlist.txt", 0)

;GUI
Opt("GUIOnEventMode", 1)
$mp3win = GUICreate("MP3 Player Z31", 400, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseDown")
$playlist = GUICtrlCreateList("", 5, 120, 395, 80)
$addsong = GUICtrlCreateButton("Add", 5, 195, 80, 23)
$delsong = GUICtrlCreateButton("Remove", 90, 195, 80, 23)
GUISetState(@SW_SHOW)

;Misc
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    GUICtrlSetData($playlist, $line)
WEnd

While 1
    Sleep(1000)
WEnd

;Functions
Func CloseDown()

    Exit
EndFunc

If you plan on testing this, than I suggest you make a test file in the script's directory called "playlist.txt" and add a few lines to it that are long enough for the need of a horizontal scroll bar....

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Adjust "GUICtrlSetLimit" value to suit your needs

Added "|" to end of $line in FileReadLine() to make list display properly

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

;loading lists and other crap
$file = FileOpen("playlist.txt", 0)

;GUI
Opt("GUIOnEventMode", 1)
$mp3win = GUICreate("MP3 Player Z31", 400, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseDown")
$playlist = GUICtrlCreateList("", 5, 120, 395, 80, BitOR($LBS_SORT,$LBS_STANDARD,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER))
$addsong = GUICtrlCreateButton("Add", 5, 195, 80, 23)
$delsong = GUICtrlCreateButton("Remove", 90, 195, 80, 23)
GUISetState(@SW_SHOW)

GUICtrlSetLimit($playlist, 1000)

;Misc
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    GUICtrlSetData($playlist, $line & "|")
WEnd

While 1
    Sleep(1000)
WEnd

;Functions
Func CloseDown()

    Exit
EndFunc
Edited by Varian

Share this post


Link to post
Share on other sites

Hmm I tried the BitOr() but not like you used it, I gave it it's own line, I didn't think to add it to the GUICtrlCreateList.

Thanks :)

Share this post


Link to post
Share on other sites

Hmm I tried the BitOr() but not like you used it, I gave it it's own line, I didn't think to add it to the GUICtrlCreateList.

Thanks :)

Actually, the GUICtrlSetLimit line is the one that counts. Without it, there is no horizontal scroll bar.

Share this post


Link to post
Share on other sites

Thank you, I will keep that in mind.

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