Jump to content

ListView Listing help


Recommended Posts

so im trying 2 make a media player that list all .mp3's in my music folder

and im using the GuiCtrlCreateListView 2 do it so u can select the song u want

heres wat i have

#NoTrayIcon
#include <GuiConstants.au3>


GuiCreate("Mizedia-Plizaya",500,300)

$filenumber = DirGetSize(@MyDocumentsDir & "\My Music\",1)





GuiCtrlCreateLabel("Media Files...(" & $filenumber[1] & ")",300,250)


$list = GuiCtrlCreateListView("Title|Artist",5,10,490,185, $LVS_SINGLESEL + $LVS_EX_FULLROWSELECT + $LVS_SHOWSELALWAYS)
$list_song = GuiCtrlCreateListViewItem("",$list)


$search = FileFindFirstFile(@MyDocumentsDir & "\My Music\*.*")



GuiSetState()
While 1
        $msg = GuiGetMsg()
            
        If $msg = $GUI_EVENT_CLOSE Then Exit
        
        $file_songs = FileFindNextFile($search)
        $sort = StringReplace($file_songs, ".mp3", "|")
        GuiCtrlSetData($list_song, $sort)

WEnd 
FileClose($search)

How Do i make it 2 where it will show all files 1 under the other

right now it shows 1 then clears the list then shows the next

so at the end i only see the last song in my music

Do i need 2 make a Func for this???

(this isnt the whole script by the way im gona add buttons and watnot)

Edited by B3TA_SCR1PT3R

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

You were setting the data instead of adding new items:

#NoTrayIcon
#include <GuiConstants.au3>


GUICreate("Mizedia-Plizaya", 500, 300)

$filenumber = DirGetSize(@MyDocumentsDir & "\My Music\", 1)





GUICtrlCreateLabel("Media Files...(" & $filenumber[1] & ")", 300, 250)


$list = GUICtrlCreateListView("Title|Artist", 5, 10, 490, 185, $LVS_SINGLESEL + $LVS_EX_FULLROWSELECT + $LVS_SHOWSELALWAYS)
;~ $list_song = GuiCtrlCreateListViewItem("",$list)


$search = FileFindFirstFile(@MyDocumentsDir & "\My Music\*.mp3")



GUISetState()
While 1
    $file_songs = FileFindNextFile($search)
    If @error Then ExitLoop
    ConsoleWrite($file_songs & @LF)
    If $file_songs <> "." And $file_songs <> ".." Then
        $sort = StringReplace($file_songs, ".mp3", "|")
        GUICtrlCreateListViewItem($sort, $list)
    EndIf
    
WEnd
FileClose($search)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
WEnd

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

You were setting the data instead of adding new items:

#NoTrayIcon
#include <GuiConstants.au3>
GUICreate("Mizedia-Plizaya", 500, 300)

$filenumber = DirGetSize(@MyDocumentsDir & "\My Music\", 1)
GUICtrlCreateLabel("Media Files...(" & $filenumber[1] & ")", 300, 250)
$list = GUICtrlCreateListView("Title|Artist", 5, 10, 490, 185, $LVS_SINGLESEL + $LVS_EX_FULLROWSELECT + $LVS_SHOWSELALWAYS)
;~ $list_song = GuiCtrlCreateListViewItem("",$list)
$search = FileFindFirstFile(@MyDocumentsDir & "\My Music\*.mp3")
GUISetState()
While 1
    $file_songs = FileFindNextFile($search)
    If @error Then ExitLoop
    ConsoleWrite($file_songs & @LF)
    If $file_songs <> "." And $file_songs <> ".." Then
        $sort = StringReplace($file_songs, ".mp3", "|")
        GUICtrlCreateListViewItem($sort, $list)
    EndIf
    
WEnd
FileClose($search)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
WEnd

Gary

<{POST_SNAPBACK}>

does this show the files in the list on ur comp?

cuz i copyed the code and it seems like its working but it just shows blank items

and then (for some odd reason) the last song shows up....

???help again plz???

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

Ok, had an if that wasn't needed.

#NoTrayIcon
#include <GuiConstants.au3>
GUICreate("Mizedia-Plizaya", 500, 300)

$filenumber = DirGetSize(@MyDocumentsDir & "\My Music\", 1)
GUICtrlCreateLabel("Media Files...(" & $filenumber[1] & ")", 300, 250)
$list = GUICtrlCreateListView("Title|Artist", 5, 10, 490, 185, BitOR($LVS_SINGLESEL, $LVS_EX_FULLROWSELECT, $LVS_SHOWSELALWAYS))
;~ $list_song = GuiCtrlCreateListViewItem("",$list)
$search = FileFindFirstFile(@MyDocumentsDir & "\My Music\*.mp3")
GUISetState()
While 1
    $file_songs = FileFindNextFile($search)
    If @error Then ExitLoop
    $sort = StringReplace($file_songs, ".mp3", "|")
    GUICtrlCreateListViewItem($sort & "| ", $list)
WEnd
FileClose($search)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

yay!!!

it worked

thanx alot

\\\\\EDIT\\\\\\\\\

the file name in my music on all files it says "song name" - "Artist"

how would i split the file name where the "-" and make half of it go to the artist colum??

i tried stringsplit but i dont know how to assign a variable 2 the other half of the split string???

help me again plzzzzz

Edited by B3TA_SCR1PT3R

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

While 1
    $file_songs = FileFindNextFile($search)
    If @error Then ExitLoop
    $sort = StringReplace($file_songs, ".mp3", "|")
    $split = StringSplit($sort, " - ")
    GUICtrlCreateListViewItem($split[1] & "|" & $split[2], $list)
WEnd

qq

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