qq342252004 发表于 2009-5-26 14:22:55

ListView问题(内有图片)

如何让二组的第一行对应的是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
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
      $pot = $pot & "|" & $var[$i]
    Next
    GUICtrlSetData($Combo1, StringMid ($pot, 1), $var)
EndIf
If FileExists($IniFile) Then
    Local $List = IniReadSection($IniFile, "第一组")
    For $i = 1 To $List
      $New_ID = UBound($Item) + 1
      ReDim $Item[$New_ID]
      $AllSound_ID = $i
      $Item[$New_ID - 1] = $List[$i]
      $TotalSounds = $TotalSounds + 1
      $bjys=GUICtrlCreateListViewItem($i & "|" & $List[$i] & "|" & $List[$i], $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
                  $New_ID = UBound($Item) + 1
                  ReDim $Item[$New_ID]
                  $AllSound_ID = $i
                  $Item[$New_ID - 1] = $List[$i]
                  $TotalSounds = $TotalSounds + 1
                                        $bjys=GUICtrlCreateListViewItem($i & "|" & $List[$i] & "|" & $List[$i], $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&$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

qq342252004 发表于 2009-5-26 23:02:39

知道的朋友 帮帮忙

seebbs 发表于 2009-6-21 18:19:08

:face (7):
页: [1]
查看完整版本: ListView问题(内有图片)