kalayaan Posted August 9, 2005 Share Posted August 9, 2005 Hi folks, My GUI has a listbox containing filepaths. and a button that does what is equivalent to a DELETE ALL function (which will delete the files and remove the items in the listbox as they are deleted). It's wierd but my FOR...NEXT loop would not delete everything. I found that at some point, $LB_GETTEXT will return some garbage in the text. Would really appreciate it if someone could take a look. THanks in advance... Here's my code... expandcollapse popup#include <GuiConstants.au3> $LBS_MULTISELECT = 80000 $LB_DELETESTRING = 0x182 $LB_GETCOUNT = 0x18B $LB_GETTEXT = 0x0189 $FileList = "c:\file01.txt|c:\file02.txt|c:\file03.txt|c:\file04.txt|c:\file05.txt|c:\file06.txt|c:\file07.txt|c:\file08.txt|c:\file09.txt" GuiCreate("LB Test", 299, 291,-1, -1) $List_1 = GuiCtrlCreateList("", 10, 10, 280, 227);,$LBS_MULTISELECT) GuiCtrlSetData(-1,$FileList) $Button_2 = GuiCtrlCreateButton("Delete ALL", 10, 250, 80, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 $items_count = _GUICtrlListCount($List_1); count the number of items in listbox For $i = 0 to $items_count - 1 $FileToDelete = _GUICtrlListGetText($List_1, $i) MsgBox(262144,'Debug line ~31','Selection:' & @lf & '$FileToDelete ' & @lf & @lf & 'Return:' & @lf & $FileToDelete & @lf & @lf & '@Error:' & @lf & @Error & @lf & @lf & '@Extended:' & @lf & @Extended);### Debug MSGBOX ; FileDelete($FileToDelete) _GUICtrlListDeleteItem($List_1, $i) Next EndSelect WEnd Func _GUICtrlListCount($h_listbox) Return GUICtrlSendMsg($h_listbox, $LB_GETCOUNT, 0, 0) EndFunc ;==>_GUICtrlListCount Func _GUICtrlListDeleteItem($h_listbox, $i_index) Return GUICtrlSendMsg($h_listbox, $LB_DELETESTRING, $i_index, 0) EndFunc ;==>_GUICtrlListDeleteItem Func _GUICtrlListGetText($h_listbox, $i_index) Return GUICtrlRecvMsg($h_listbox, $LB_GETTEXT, $i_index, 1) EndFunc ;==>_GUICtrlListGetText Link to comment Share on other sites More sharing options...
GaryFrost Posted August 9, 2005 Share Posted August 9, 2005 no bug just just your for loop For $i = $items_count - 1 to 0 Step -1 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Zedna Posted August 10, 2005 Share Posted August 10, 2005 Func _GUICtrlListGetText($h_listbox, $i_index) Return GUICtrlRecvMsg($h_listbox, $LB_GETTEXT, $i_index, 1) EndFunc ;==>_GUICtrlListGetText<{POST_SNAPBACK}>It should be:Func _GUICtrlListGetText($h_listbox, $i_index) Return GUICtrlSendMsg($h_listbox, $LB_GETTEXT, $i_index, 1) EndFunc ;==>_GUICtrlListGetTextGUICtrlRecvMsg --> GUICtrlSendMsg Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
kalayaan Posted August 11, 2005 Author Share Posted August 11, 2005 (edited) @gafrost, by god, you're right. I'm laughing at myself as I type. too embarassing. :"> . I should've guessed the items would be renumbered after each deletion. Glad I don't do this for a living. Thanks again and until my next booboo. Edited August 11, 2005 by kalayaan Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now