找回密码
 加入
搜索
查看: 1596|回复: 2

ListView问题(内有图片)

[复制链接]
发表于 2009-5-26 14:22:55 | 显示全部楼层 |阅读模式
如何让二组的第一行对应的是4mp3.mp3,三组的第一行对应的是7mp3.mp3   ?
[第一组]
1=e:\1mp3.mp3
2=e:\2mp3.mp3
3=e:\3mp3.mp3
[第二组]
4=e:\4mp3.mp3
5=e:\5mp3.mp3
6=e:\6mp3.mp3
[第三组]
7=e:\7mp3.mp3
8=e:\8mp3.mp3
9=e:\9mp3.mp3
#include <Audio.au3> 
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $IniFile = @ScriptDir & "\txt.txt"
Dim $Item[1]
Dim $pot = ""
Dim $soundLoad_id, $click_id 
Global Const $DebugIt = 1 
Dim $TotalSounds = 0 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("ListView", 167, 311, -1, -1)
$Combo1 = GUICtrlCreateCombo("", 8, 24, 145, 25)
$lvs1 = GuiCtrlCreateListView("编号|歌曲名称|歌曲路径",8,56, 140, 214)
$Button1 = GUICtrlCreateButton("播放", 48, 280, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var = IniReadSectionNames($IniFile)
If @error Then 
Else
    For $i = 1 To $var[0]
        $pot = $pot & "|" & $var[$i]
    Next
    GUICtrlSetData($Combo1, StringMid ($pot, 1), $var[1]) 
EndIf
If FileExists($IniFile) Then 
    Local $List = IniReadSection($IniFile, "第一组") 
    For $i = 1 To $List[0][0] 
        $New_ID = UBound($Item) + 1 
        ReDim $Item[$New_ID] 
        $AllSound_ID = $i 
        $Item[$New_ID - 1] = $List[$i][1] 
        $TotalSounds = $TotalSounds + 1 
        $bjys=GUICtrlCreateListViewItem($i & "|" & $List[$i][0] & "|" & $List[$i][1], $lvs1) 
                If Round($I / 2) = $I / 2 Then GUICtrlSetBkColor($bjys, 0xEEEEEE)
    Next 
EndIf 
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Combo1
                         _GUICtrlListView_DeleteAllItems($lvs1)
                        If FileExists($IniFile) Then 
                Local $List = IniReadSection($IniFile, GUICtrlRead($Combo1)) 
                For $i = 1 To $List[0][0] 
                    $New_ID = UBound($Item) + 1 
                    ReDim $Item[$New_ID] 
                    $AllSound_ID = $i 
                    $Item[$New_ID - 1] = $List[$i][1] 
                    $TotalSounds = $TotalSounds + 1 
                                        $bjys=GUICtrlCreateListViewItem($i & "|" & $List[$i][0] & "|" & $List[$i][1], $lvs1) 
                            If Round($I / 2) = $I / 2 Then GUICtrlSetBkColor($bjys, 0xEEEEEE)
                Next 
                        EndIf
                Case $Button1
                        
        EndSwitch
WEnd


Func myplay($in_id) 
    _SoundStop($soundLoad_id) 
    $play_ID = $in_id 
    _GuiCtrlListView_SetItemSelected ($lvs1, ($play_ID - 1)) 
        $aItem2 = _GUICtrlListView_GetItemTextArray ($lvs1, ($play_ID - 1)) 
    $soundLoad_id = _SoundOpen($Item[$play_ID])
    MsgBox(0,"播放歌曲",$aItem2[2]&$Item[$play_ID])        
    _SoundPlay($soundLoad_id) 
    $aItem2 = _GUICtrlListView_GetItemTextArray ($lvs1, ($play_ID - 1)) 
    AdlibEnable("display", 1000) 
EndFunc

Func display() 
    Local $ptime, $totaltime 
    $ptime = _SoundPos($soundLoad_id) 
    $totaltime = _SoundLength($soundLoad_id) 
    If $ptime = $totaltime Then 
        $play_ID = $play_ID + 1 
        If $play_ID >= UBound($Item) Then $play_ID = 1 
        myplay($play_ID) 
    EndIf 
EndFunc

; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
        #forceref $hWndGUI, $MsgID, $wParam
        Local $tagNMHDR, $event, $hwndFrom, $code
        $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
        If @error Then Return
        $event = DllStructGetData($tagNMHDR, 3)
        Select
                Case $wParam = $lvs1
                        Select
                                Case $event = $NM_CLICK
                                        ListView_Click()
                                Case $event = $NM_DBLCLK
                                        ListView_DoubleClick()
                        EndSelect
                        
        EndSelect
        $tagNMHDR = 0
        $event = 0
        $lParam = 0
EndFunc   ;==>WM_Notify_Events

Func ListView_Click() 
    If $DebugIt Then _DebugPrint("$NM_CLICK") 
EndFunc

Func ListView_DoubleClick() 
    If $DebugIt Then _DebugPrint("$NM_DBLCLK") 
    $click_id = Number(_GUICtrlListView_GetSelectedIndices ($lvs1)) + 1 
    myplay($click_id) 
EndFunc

Func _DebugPrint($s_text) 
    ConsoleWrite( _ 
            "!===========================================================" & @LF & _ 
            "+===========================================================" & @LF & _ 
            "-->" & $s_text & @LF & _ 
            "+===========================================================" & @LF) 
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-5-26 23:02:39 | 显示全部楼层
知道的朋友 帮帮忙
发表于 2009-6-21 18:19:08 | 显示全部楼层
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-26 12:38 , Processed in 0.077280 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表