Sign in to follow this  
Followers 0
kenh015

GUICtrlCreateListView

3 posts in this topic

#1 ·  Posted (edited)

Hi, I have a collection of avi movies and am attempting to create an autoplay function that will play the movies using Portable VLC Player from a DVD. The program will search @ScriptDir for any .avi files then list them in a window. I found (at least where I work) that the DVD codecs are not installed on all PC's which is the reason for the portable player. My issue is that I can get the list of movies to come up fine, and even select them and play the movies...but I can't seem to get the window to come up with only one column, or have the main column sized to fit all of the characters of the file name. If anyone can let me know what I am doing wrong I would be most appreciative.

Thank you,

Here's the code...

#Include <File.au3>
#Include <Array.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>

$sprache = ObjCreate("SAPI.SpVoice")
;This line makes the computer talk to you before opening the menu...thought it might be fun
_Talk("Please select a movie from the list and press play.")

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $Btn_Play, $ilistitem, $msg, $Status, $pos, $current, $MovieList, $FileList
GUICreate("Movie Play List", 392, 322)


$listview = GUICtrlCreateListView("Movie to Play", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
;~ GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)



$MovieList = _FileList()
For $n = 1 To (UBound ($MovieList) -1)
    GUICtrlCreateListViewItem($MovieList[$n],$listview)
Next

$Btn_Play = GUICtrlCreateButton("Play",150,260,70,30)
$Status = GUICtrlCreateLabel("PLEASE SELECT A MOVIE", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$current = _GUICtrlListViewGetHotItem ($listview)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $Btn_Play
            _PlayMovie()
            
        Case Else
            $pos = GUIGetCursorInfo()
            If ($pos[4] == $listview) Then
                If ($current <> _GUICtrlListViewGetHotItem ($listview) And _GUICtrlListViewGetHotItem ($listview) >= 0) Then
                    GUICtrlSetData($Status, "Movie: " & _GUICtrlListViewGetHotItem ($listview))
                    $current = _GUICtrlListViewGetHotItem ($listview)
                ElseIf (_GUICtrlListViewGetHotItem ($listview) == -1) Then
                    GUICtrlSetData($Status, "")
                EndIf
            EndIf
    EndSelect
WEnd
Exit

func _FileList()
    $FileList=_FileListToArray(@ScriptDir,"*.avi")
    If (Not IsArray($FileList)) and (@Error=1) Then
        MsgBox (0,"","No Files\Folders Found.")
        Exit
    EndIf
    ;~  _ArrayDelete($FileList,0)
;~  _ArrayDisplay($FileList,"Movies on Disk")
    return $FileList
    EndFunc


Func _PlayMovie()
    $ilistitem = _GUICtrlListViewGetCurSel($listview)
    if $ilistitem == -1 Then
        MsgBox(48,"ERROR NOTHING SELECTED","Please select a movie to play! Dumbass!!")
        Else
    $current =_GUICtrlListViewGetItemText($listview,$ilistitem)
    run(@ScriptDir & '\portablevlc\portablevlc.exe "' & $current & '"')
    WinSetState("Movie Play List","", @SW_HIDE)
    winwaitactive("VLC")
    winwaitclose("VLC")
    WinSetState("Movie Play List","", @SW_show)
    EndIf
    EndFunc

Func _Talk($text)
    $sprache.Speak($text)
    EndFunc
Edited by kenh015

Share this post


Link to post
Share on other sites



#Include <File.au3>
#Include <Array.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>

$sprache = ObjCreate("SAPI.SpVoice")
;This line makes the computer talk to you before opening the menu...thought it might be fun
_Talk("Please select a movie from the list and press play.")

Opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $Btn_Play, $ilistitem, $msg, $Status, $pos, $current, $MovieList, $FileList
GUICreate("Movie Play List", 392, 322)


$listview = GUICtrlCreateListView("Movie to Play", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
;~ GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
_GUICtrlListViewSetColumnWidth($listview, 0, $LVSCW_AUTOSIZE_USEHEADER)


$MovieList = _FileList()
For $n = 1 To (UBound($MovieList) - 1)
    GUICtrlCreateListViewItem($MovieList[$n], $listview)
Next

$Btn_Play = GUICtrlCreateButton("Play", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("PLEASE SELECT A MOVIE", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$current = _GUICtrlListViewGetHotItem($listview)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

        Case $msg = $Btn_Play
            _PlayMovie()

        Case Else
            $pos = GUIGetCursorInfo()
            If ($pos[4] == $listview) Then
                If ($current <> _GUICtrlListViewGetHotItem($listview) And _GUICtrlListViewGetHotItem($listview) >= 0) Then
                    GUICtrlSetData($Status, "Movie: " & _GUICtrlListViewGetHotItem($listview))
                    $current = _GUICtrlListViewGetHotItem($listview)
                ElseIf (_GUICtrlListViewGetHotItem($listview) == -1) Then
                    GUICtrlSetData($Status, "")
                EndIf
            EndIf
    EndSelect
WEnd
Exit

Func _FileList()
    $FileList = _FileListToArray(@ScriptDir, "*.avi")
    If (Not IsArray($FileList)) And (@error = 1) Then
        MsgBox(0, "", "No Files\Folders Found.")
        Exit
    EndIf
;~ _ArrayDelete($FileList,0)
;~ _ArrayDisplay($FileList,"Movies on Disk")
    Return $FileList
EndFunc   ;==>_FileList


Func _PlayMovie()
    $ilistitem = _GUICtrlListViewGetCurSel($listview)
    If $ilistitem == -1 Then
        MsgBox(48, "ERROR NOTHING SELECTED", "Please select a movie to play! Dumbass!!")
    Else
        $current = _GUICtrlListViewGetItemText($listview, $ilistitem)
        Run(@ScriptDir & '\portablevlc\portablevlc.exe "' & $current & '"')
        WinSetState("Movie Play List", "", @SW_HIDE)
        WinWaitActive("VLC")
        WinWaitClose("VLC")
        WinSetState("Movie Play List", "", @SW_SHOW)
    EndIf
EndFunc   ;==>_PlayMovie

Func _Talk($text)
    $sprache.Speak ($text)
EndFunc   ;==>_Talk


SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites

Thank you for the update. I feel like a complete idiot for missing that. :P

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