Sign in to follow this  
Followers 0
Libre

Posible Bug With _guictrllistviewdeleteitem

14 posts in this topic

#1 ·  Posted (edited)

i want to delete all the same lines in a listview.

and i aply this script to a long listview to delete all the DUPLICATE LINES.

_GUICtrlListViewSort($List_Drv, $B_DESCENDING, 0)
DeleteDup($List_Drv)

Func DeleteDup($List_view)

     for $i= 0 to _GUICtrlListViewGetItemCount($List_view)

             if _GUICtrlListViewGetItemText ($List_view,$i,0) == $LV_ERR  then ExitLoop

             if _GUICtrlListViewGetItemText ($List_view,$i,0) ==  _GUICtrlListViewGetItemText ($List_view,$i+1,0) Then
               
                    _GUICtrlListViewDeleteItem($List_view, $i)
                    $i = $i -1

             EndIf

     Next

EndFunc

After this, windows only responses when i minimize and restore the windows. i think is rare dÖob

can someone say me what is bad?

Edited by Libre

I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!?

Share this post


Link to post
Share on other sites



Sounds like a support questions to me... not a bug report. -> moving post

You probably need to post more so we can duplicate the issue you see...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Well, i hope here we found the answer. thanks :)


I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!?

Share this post


Link to post
Share on other sites

did you also see the question ?

The question is, why it blocks , and only works when i minimize and restores de windows ?

I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!?

Share this post


Link to post
Share on other sites

The question is, why it blocks , and only works when i minimize and restores de windows ?

NoNo.. I think we need more of your script to be able to test and see why you get this "Hanging" window...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

think your DeleteDup func has a logic eror.

It should not test the last value:

For $i = 0 To _GUICtrlListViewGetItemCount ($list_view) -1


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

i think your anwer will better, after try that yourself. Is NOT the error u said. it works fine.

Not sure what you mean/suggest but the code you posted went into a endless loop with the Value of I being 199 .....So I did test the posted code (not the attached) and when I changed the code the list showed...

and when you change the While...wend loop to:

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

the CloseWindow also works fine....

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

think your DeleteDup func has a logic eror.

It should not test the last value:

For $i = 0 To _GUICtrlListViewGetItemCount ($list_view) -1

also should go in reverse, because you'll delete an index and it changes the index for the remainder

i.e.

For $i = _GUICtrlListViewGetItemCount ($list_view) -1 to 0

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

#10 ·  Posted (edited)

well sorry, for the last posts.

this is the finaly script will show you the real problem.

run it , please.

#include <GuiConstants.au3>
#include <GuiListView.au3>

GUICreate("", 480, 390, 348, 128,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$list_view = GUICtrlCreateListView("--- |----|----|----|---|--",30, 60, 420, 150,BitOR($LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS))
$BotonRefresh = GUICtrlCreateButton("Refresh", 120, 216, 81, 33, 0,$BS_MULTILINE)
$cap    = GUICtrlCreateLabel("try to refresh one time, and then if dont work, minimize and restores the window", 30, 255, 230, 35,$BS_MULTILINE)

GUISetState(@SW_SHOW)


showlist()


While 1
    $msg = GuiGetMsg()
    
    Select
        
    Case $msg = $GUI_EVENT_CLOSE                                         
    
        ExitLoop
    
    Case $msg = $BotonRefresh
    
         showlist()
         
        
    EndSelect

WEnd

func showlist()
    _GUICtrlListViewDeleteAllItems($list_view)
    dim $DataSubItem[7] 
    
    Dim $B_DESCENDING[6]

;GUICtrlSetState ( $list_view, $GUI_HIDE    )
;GUICtrlSetState ( $list_view, $GUI_DISABLE)
    For $i= 1 to 100
        
            $DataSubItem[1] = $i * 1
            $DataSubItem[5] = $i * 2
            $DataSubItem[3] = $i * 3
            $DataSubItem[4] = $i * 4
            $DataSubItem[2] = round ( $i * 5 / 10 )
            $DataSubItem[6] = $i * 6
            
            GUICtrlCreateListViewItem( $DataSubItem[2] & "|" & $DataSubItem[3] & "|" &$DataSubItem[4] & "|" & $DataSubItem[5] & "|" & $DataSubItem[1] & "|" & $DataSubItem[6],$list_view)
        
    Next
    
    
    _GUICtrlListViewSort($list_view, $B_DESCENDING, 0)
    
    DeleteDup($List_view)
        
EndFunc

Func DeleteDup($List_view)

    for $i= 0 to _GUICtrlListViewGetItemCount($List_view) -1
        if _GUICtrlListViewGetItemText ($List_view,$i,0) == $LV_ERR  then ExitLoop

        if _GUICtrlListViewGetItemText ($List_view,$i,0) ==  _GUICtrlListViewGetItemText ($List_view,$i+1,0) Then
              
            _GUICtrlListViewDeleteItem($List_view, $i)
            $i = $i -1

        EndIf
    Next

EndFunc
Edited by Libre

I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!?

Share this post


Link to post
Share on other sites

Func DeleteDup($list_view)
    $end = _GUICtrlListViewGetItemCount ($list_view) - 1
    For $i = 0 To $end
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop
        
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then
            
            _GUICtrlListViewDeleteItem ($list_view, $i)
            $end = _GUICtrlListViewGetItemCount ($list_view) - 1
        EndIf
    Next
    
EndFunc  ;==>DeleteDup


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

as GAFROST suggested : with this changed DeleteDup() func things work fine... I can keep on clicking refresh:

Func DeleteDup($list_view)
    For $i = _GUICtrlListViewGetItemCount ($list_view) To 2 Step -1
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then
            _GUICtrlListViewDeleteItem ($list_view, $i)
        EndIf
    Next
EndFunc  ;==>DeleteDup

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Func DeleteDup($list_view)
    $end = _GUICtrlListViewGetItemCount ($list_view) - 1
    For $i = 0 To $end
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop
        
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then
            
            _GUICtrlListViewDeleteItem ($list_view, $i)
            $end = _GUICtrlListViewGetItemCount ($list_view) - 1
        EndIf
    Next
    
EndFunc ;==>DeleteDup
THANKS SO MUCH, now it works.

I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Func DeleteDup($list_view)
    $end = _GUICtrlListViewGetItemCount ($list_view) - 1
    For $i = 0 To $end
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop
        
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then
            
            _GUICtrlListViewDeleteItem ($list_view, $i)
            $end = _GUICtrlListViewGetItemCount ($list_view) - 1
        EndIf
    Next
    
EndFunc;==>DeleteDup
thanks man. i was needing that help. but u forgot that line :)

Func DeleteDup($list_view)
    $end = _GUICtrlListViewGetItemCount ($list_view) - 1
    For $i = 0 To $end
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == $LV_ERR Then ExitLoop
        
        If _GUICtrlListViewGetItemText ($list_view, $i, 0) == _GUICtrlListViewGetItemText ($list_view, $i + 1, 0) Then
            
            _GUICtrlListViewDeleteItem ($list_view, $i)
            $end = _GUICtrlListViewGetItemCount ($list_view) - 1
            if $i <= $end then $i = $i - 1; <-------------------< Now no one duplicated
        EndIf
    Next
    
EndFunc;==>DeleteDup
Edited by Libre

I love this Game :p----------------------Freeware Multilange support or Translate your scripts----------------------aNyBoDy KnOwS WhY A LiGhT iN My KeYbOaRd iS aLlWaIs BlInKiNg !?Who is "General Failure" and what is he doing in my hard disk !!!!!?

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