Probleme mit Listview Item

  • ?( Dubios, Dubios ... oder ich sehe die Bäume vor lauter Wald nicht mehr :thumbdown:
    Hallo Alle,
    ich ein Script welches ein Listview anzeigt. Beim Laden des Scripts werden alle Items inklusive der Subitems richtig erzeugt. Wil ich später einen neuen Eintrag hinzufügen, klappt es nicht mehr.

    Kann jemand mal schauen. Es betrifft den Zeilenblock 37-44 (funktioniert) sowie den Block 60-69.

    Danke im voraus.

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EDIT: Hat sich soeben erledigt! ^^
    #include <Constants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <ProgressConstants.au3>
    #include <SendMessage.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global Const $SW_HIDE = 0
    Global Const $SW_SHOW = 5

    [/autoit] [autoit][/autoit] [autoit]

    ;Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    _Main()

    [/autoit] [autoit][/autoit] [autoit]

    Func _Main()
    Local $listview
    Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES)

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("ImageList Add", 461, 300)
    $listview = GUICtrlCreateListView("", 2, 2, 460, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
    $PB_NewItem = GUICtrlCreateButton("Neuer Eintrag", 2, 275, 75, 20)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; Load images

    [/autoit] [autoit][/autoit] [autoit]

    ; Add columns
    _GUICtrlListView_AddColumn($listview, "", 25)
    _GUICtrlListView_AddColumn($listview, "Nr", 35)
    _GUICtrlListView_AddColumn($listview, "Titel", 200)
    _GUICtrlListView_AddColumn($listview, "Fortschritt", 250)

    [/autoit] [autoit][/autoit] [autoit]

    ; Add items
    for $z = 0 to Random(5,10,1)
    _GUICtrlListView_AddItem($listview, "")
    _GUICtrlListView_AddSubItem($ListView, $z, $z+1, 1, 1)
    _GUICtrlListView_AddSubItem($ListView, $z, "Seite " & $z+1 & " holen", 2, 2)
    _GUICtrlListView_AddSubItem($ListView, $z, "Warte auf Start!", 3, 2)

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    dim $downloaded_nr = 0

    [/autoit] [autoit][/autoit] [autoit]

    dim $querystring = "http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=*author=7600CELSIUS"
    #cs
    Local $hProgress = _ListView_InsertProgressBar($listview, 0, 3)
    _Progress_SetBarColor($hProgress, 0x0000FF)
    _Progress_SetBkColor($hProgress,0x00FFFF)
    #ce

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Loop until user exits
    Local $i, $listitemctr = 0

    [/autoit] [autoit][/autoit] [autoit]

    Do

    [/autoit] [autoit][/autoit] [autoit]

    if GUIGetMsg() = $PB_NewItem then

    [/autoit] [autoit][/autoit] [autoit]

    $z = _GUICtrlListView_GetItemCount($ListView) + 1
    ConsoleWrite("$pb_newitem: " & $z & @crlf)
    _GUICtrlListView_AddItem($listview, "")
    _GUICtrlListView_AddSubItem($ListView, $z, $z+1, 1, 1)
    _GUICtrlListView_AddSubItem($ListView, $z, "Seite " & $z+1 & " holen", 2, 2)
    _GUICtrlListView_AddSubItem($ListView, $z, "Warte auf Start!", 3, 2)

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    for $i = 0 to _GUICtrlListView_GetItemCount($ListView)
    if $listitemctr = _GUICtrlListView_GetItemCount($ListView) then ExitLoop
    Local $hDownload = InetGet("http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=" & $i + 1 & "&author=7600CELSIUS", @ScriptDir & "\update" & $i + 1 & ".dat", 1, 1)
    Do
    Sleep(50)
    Local $nBytes = InetGetInfo($hDownload, 0)
    _GUICtrlListView_SetItemText($ListView, $i, "Runterläding: " & $nBytes, 3)
    if GUIGetMsg() = $GUI_EVENT_CLOSE then
    InetClose($hDownload) ; Close the handle to release resourcs.
    GUIDelete()
    Exit
    EndIf
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $nBytes = ' & $nBytes & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    Until InetGetInfo($hDownload, 2); Check if the download is complete.
    Local $nBytes = InetGetInfo($hDownload, 0)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $nBytes ' & $i & ' = ' & $nBytes & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    InetClose($hDownload) ; Close the handle to release resourcs.
    $olditem = _GUICtrlListView_GetItemText($ListView, $i, 3)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $olditem = ' & $olditem & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    If $olditem = "Runterläding: 0" Then
    _GUICtrlListView_SetItemText($ListView, $i, "Fehler: Keine Internetverbindung!", 3)
    Else
    _GUICtrlListView_SetItemText($ListView, $i, "Fertig!", 3)
    EndIf
    $listitemctr = $listitemctr + 1
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : GUIGetMsg = ' & GUIGetMsg() & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Sleep(50)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE ;Or $i = 101

    [/autoit] [autoit][/autoit] [autoit]

    GUIDelete()
    EndFunc ;==>_Main

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ======================================================================================
    ; Function Name:_ListView_InsertProgressBar()
    ; Description: Inserts a progressbar control in the ListView control.
    ; Syntax.........: _ListView_InsertProgressBar($sHwnd, $sItemIndex[, $sSubItemIndex])
    ; Parameter(s): $sHwnd - Handle to the ListView control.
    ; $sItemIndex - Zero based index of the item at which the progressbar should be inserted.
    ; $sSubItemIndex - [Optional] One based index of the subitem where progressbar should be placed, default is 1.
    ;
    ; Return Value(s): Returns the identifier (controlID) of the new progressbar control.
    ; Requirement(s): AutoIt 3.2.10.0 and above
    ; Note(s): Optimal amount of progressbar controls is 5-10. Don`t abuse with many amount of progressbar controls.
    ;
    ; Author(s): R.Gilman (a.k.a rasim), arcker
    ;==================================================================================================
    Func _ListView_InsertProgressBar($sHwnd, $sItemIndex, $sSubItemIndex = 0)
    Local $hRet
    If Not IsHWnd($sHwnd) Then $sHwnd = GUICtrlGetHandle($sHwnd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iStyle = _WinAPI_GetWindowLong($sHwnd, $GWL_STYLE)

    [/autoit] [autoit][/autoit] [autoit]

    If BitAND($iStyle, $WS_CLIPCHILDREN) <> $WS_CLIPCHILDREN Then
    _WinAPI_SetWindowLong($sHwnd, $GWL_STYLE, BitOR($iStyle, $WS_CLIPCHILDREN))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRect

    [/autoit] [autoit][/autoit] [autoit]

    If $sSubItemIndex = 0 Then
    $aRect = _GUICtrlListView_GetItemRect($sHwnd, $sItemIndex, 2)
    Else
    $aRect = _GUICtrlListView_GetSubItemRect($sHwnd, $sItemIndex, $sSubItemIndex)
    EndIf
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
    $hRet = _Progress_Create($sHwnd, $aRect[0], $aRect[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1])
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7)

    [/autoit] [autoit][/autoit] [autoit]

    Return $hRet
    EndFunc ;==>_ListView_InsertProgressBar

    [/autoit] [autoit][/autoit] [autoit]

    Func _Progress_Create($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $iStyle = 0, $iExStyle = 0)
    $iStyle = BitOR($iStyle, $WS_CHILD, $WS_VISIBLE)
    Return _WinAPI_CreateWindowEx($iExStyle, "msctls_progress32", "", $iStyle, $iX, $iY, $iWidth, $iHeight, $hWnd)
    EndFunc ;==>_Progress_Create
    Func _MoveProgress($hListView, $hProgress, $sItemIndex, $sSubItemIndex)
    Local $aRect

    [/autoit] [autoit][/autoit] [autoit]

    If $sSubItemIndex = 0 Then
    $aRect = _GUICtrlListView_GetItemRect($hListView, $sItemIndex, 2)
    Else
    $aRect = _GUICtrlListView_GetSubItemRect($hListView, $sItemIndex, $sSubItemIndex)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $aRect[1] < 10 Then
    _WinAPI_ShowWindow($hProgress, $SW_HIDE)
    ElseIf $aRect[1] >= 10 Then
    _WinAPI_ShowWindow($hProgress, $SW_SHOW)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_MoveWindow($hProgress, $aRect[0], $aRect[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1], True)
    EndFunc ;==>_MoveProgress

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================
    ; Description ...: Sets the color of the indicator bar
    ; Parameters ....: $hWnd - Handle to the control
    ; $iColor - The new progress indicator bar color. Specify the CLR_DEFAULT value to cause the progress bar
    ; +to use its default progress indicator bar color.
    ; Return values .: Success - The previous progress indicator bar color, or CLR_DEFAULT if the progress indicator bar color
    ; +is the default color.
    ; Author ........: Paul Campbell (PaulIA), Updated By Arcker
    ; Remarks .......: This message is supported only in the Windows Classic theme
    ; Related .......:
    ; ====================================================================================================
    Func _Progress_SetBarColor($hWnd, $iColor)
    Return _SendMessage($hWnd, $PBM_SETBARCOLOR, 0, $iColor)
    EndFunc ;==>_Progress_SetBarColor

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================
    ; Description ...: Sets the current position
    ; Parameters ....: $hWnd - Handle to the control
    ; $iPos - The new position
    ; Return values .: Success - The previous position
    ; Author ........: Paul Campbell (PaulIA), Updated By Arcker
    ; Remarks .......:
    ; Related .......: _Progress_GetPos
    ; ====================================================================================================
    Func _Progress_SetPos($hWnd, $iPos)
    Return _SendMessage($hWnd, $PBM_SETPOS, $iPos, 0)
    EndFunc ;==>_Progress_SetPos

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================
    ; Description ...: Sets the background color in the progress bar
    ; Parameters ....: $hWnd - Handle to the control
    ; $iColor - The new background color. Specify the CLR_DEFAULT value to cause the progress bar to use its
    ; +default background color.
    ; Return values .: Success - The previous background color, or CLR_DEFAULT if the background color is the default color.
    ; Author ........: Paul Campbell (PaulIA), Updated By Arcker
    ; Remarks .......: This message is supported only in the Windows Classic theme
    ; Related .......:
    ; ====================================================================================================
    Func _Progress_SetBkColor($hWnd, $iColor)
    Return _SendMessage($hWnd, $PBM_SETBKCOLOR, 0, $iColor)
    EndFunc ;==>_Progress_SetBkColor

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; Description ...: Specifies the step increment
    ; Parameters ....: $hWnd - Handle to the control
    ; $iStep - Step increment.
    ; Return values .: Success - The previous step increment
    ; Author ........: Paul Campbell (PaulIA)
    ; Remarks .......: The step increment is the amount by which the progress bar increases its current position whenever you use the
    ; _Progress_StepIt function. By default, the step increment is set to 10.
    ; Related .......: _Progress_StepIt
    ; ====================================================================================================
    Func _Progress_SetStep($hWnd, $iStep = 10)
    Return _SendMessage($hWnd, $PBM_SETSTEP, $iStep, 0)
    EndFunc ;==>_Progress_SetStep

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================
    ; Description ...: Advances the current position by the step increment
    ; Parameters ....: $hWnd - Handle to the control
    ; Return values .: Success - The previous position
    ; Author ........: Paul Campbell (PaulIA), Updated By Arcker
    ; Remarks .......:
    ; Related .......: _Progress_SetStep
    ; ====================================================================================================
    Func _Progress_StepIt($hWnd)
    Return _SendMessage($hWnd, $PBM_STEPIT, 0, 0)
    EndFunc ;==>_Progress_StepIt

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================
    ; Description ...: Delete the progressbar control
    ; Parameters ....: $hWnd - Handle to the control
    ; Return values .: Success - True
    ; Failure - False
    ; Author ........: G. Sandler (MrCreatoR), Updated by rasim
    ; Remarks .......:
    ; Related .......: _Progress_SetStep
    ; ====================================================================================================
    Func _Progress_Delete($hWnd)
    Local $aResult = DllCall("User32.dll", "int", "DestroyWindow", "hwnd", $hWnd)
    If @error Then Return SetError(1, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Return $aResult[0] <> 0
    EndFunc ;==>_Progress_Delete

    [/autoit]

    Einmal editiert, zuletzt von fschaef (30. Juli 2011 um 18:52)