benners Posted November 26, 2007 Share Posted November 26, 2007 I have created a GUI with Koda and have a list view on the GUI. I have updated my script to use the new GUIListView.au3 which has fooked my up no end and am having trouble understanding the new commands, I just need someone to slap me and explain the obvious. The old code to create the list view and delete the items was $Hotfix_lv = GUICtrlCreateListView("KB Number|Description|Filename|Original Filename", 14, 98, 415, 250, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) _GUICtrlListViewDeleteAllItems($Hotfix_lv) The new code I am using is $Hotfix_lv = GUICtrlCreateListView("KB Number|Description|Filename|Original Filename", 14, 98, 415, 250, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) _GUICtrlListView_DeleteAllItems($Hotfix_lv) I have read the new help file and it seems to me that this should work as the code given is _GUICtrlListView_DeleteAllItems($hListView) although in the example the listview is created with _GUICtrlListView_Create, but when my code runs I get an error saying Use GUICtrlDelete to delete items Or if items were created with UDF functions MAKE sure to pass in handle to control NOT the controlidIt seems to me that the code is trying to delete the listview not the items so what would the control handle be if the controlId is $Hotfix_lv?. Can anyone shed an light on what I'm doing wrong?. Thanks. Link to comment Share on other sites More sharing options...
Generator Posted November 26, 2007 Share Posted November 26, 2007 _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($Hotfix_lv)) Link to comment Share on other sites More sharing options...
GaryFrost Posted November 26, 2007 Share Posted November 26, 2007 (edited) I have created a GUI with Koda and have a list view on the GUI. I have updated my script to use the new GUIListView.au3 which has fooked my up no end and am having trouble understanding the new commands, I just need someone to slap me and explain the obvious. The old code to create the list view and delete the items was $Hotfix_lv = GUICtrlCreateListView("KB Number|Description|Filename|Original Filename", 14, 98, 415, 250, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) _GUICtrlListViewDeleteAllItems($Hotfix_lv) The new code I am using is $Hotfix_lv = GUICtrlCreateListView("KB Number|Description|Filename|Original Filename", 14, 98, 415, 250, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) _GUICtrlListView_DeleteAllItems($Hotfix_lv) I have read the new help file and it seems to me that this should work as the code given is _GUICtrlListView_DeleteAllItems($hListView) although in the example the listview is created with _GUICtrlListView_Create, but when my code runs I get an error saying It seems to me that the code is trying to delete the listview not the items so what would the control handle be if the controlId is $Hotfix_lv?. Can anyone shed an light on what I'm doing wrong?. Thanks. Means you should use GuiCtrlDelete or get the handle to the listview. If you used GUICtrlCreateListViewItem to create the items you shoud use the GuiCtrlDelete. If you created the items using the UDF function then you just need the get the handle to the listview and pass that in. Edited November 26, 2007 by GaryFrost 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...
benners Posted November 27, 2007 Author Share Posted November 27, 2007 @Generator Thanks your code worked, but there is still something I don't understand. I use other commands from the GuiListView udf and according to the help file they also use the same syntax i.e _GUICtrlListView_GetSelectedCount($hWnd) $hWnd being the handle to the control and my code is _GUICtrlListView_GetSelectedCount($Hotfix_lv)where $Hotfix_lv is the handle. The _GUICtrlListView_DeleteAllItems is the only one I am having problems with and that I need to get the controls handle for, that I can currently see. Some of the ones that accept $Hotfix_lv as the handle are :- _GUICtrlListView_SetItemChecked _GUICtrlListView_SetColumnWidth _GUICtrlListView_GetItemCount _GUICtrlListView_GetItemChecked I have also found that if I uninstall all the AutoIt stuff and start a fresh I can get it to work with my original code. The process goes like this :- Install the latest AutoIt exe (v3.2.10.0) run the script and the error is produced. Install the latest Beta (v3.1.9.14), use Toggle AU3 Beta to change to the latest Beta, run the script and the error is produced. Install the latest SciTE (11/15/2007) run the script and the error is produced. Use "Beta Run" from the SciTE menu and the code works. Can anyone explain this?. Thanks. Link to comment Share on other sites More sharing options...
GaryFrost Posted November 27, 2007 Share Posted November 27, 2007 @Generator Thanks your code worked, but there is still something I don't understand. I use other commands from the GuiListView udf and according to the help file they also use the same syntax i.e _GUICtrlListView_GetSelectedCount($hWnd) $hWnd being the handle to the control and my code is _GUICtrlListView_GetSelectedCount($Hotfix_lv)where $Hotfix_lv is the handle. The _GUICtrlListView_DeleteAllItems is the only one I am having problems with and that I need to get the controls handle for, that I can currently see. Some of the ones that accept $Hotfix_lv as the handle are :- _GUICtrlListView_SetItemChecked _GUICtrlListView_SetColumnWidth _GUICtrlListView_GetItemCount _GUICtrlListView_GetItemChecked I have also found that if I uninstall all the AutoIt stuff and start a fresh I can get it to work with my original code. The process goes like this :- Install the latest AutoIt exe (v3.2.10.0) run the script and the error is produced. Install the latest Beta (v3.1.9.14), use Toggle AU3 Beta to change to the latest Beta, run the script and the error is produced. Install the latest SciTE (11/15/2007) run the script and the error is produced. Use "Beta Run" from the SciTE menu and the code works. Can anyone explain this?. Thanks. Yeah it was a last minute bug fix before the release, and it is not a bug, it is designed that way, it is to hard to guess if the item(s) are created with the built-in or the UDFs and using the delete of the UDFS sometimes deletes the control itself the old way. 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...
Generator Posted November 27, 2007 Share Posted November 27, 2007 _GUICtrlListView_GetSelectedCount(GUICtrlGetHandle($Hotfix_lv)) If you read the help file, when you create a new control, in most cases, it Returns the identifier (controlID) of the new control.but not the handle Therefore you need to use GUICtrlGetHandle to retrieve the handle to work with the new UDF. Link to comment Share on other sites More sharing options...
therks Posted November 27, 2007 Share Posted November 27, 2007 You are not supposed to do it like that.Read this thread: http://www.autoitscript.com/forum/index.ph...mp;#entry437879To summarize: Do not use _GUICtrlListView_DeleteAllItems() UNLESS you created the ListView and it's items with _GUICtrlListView_Create, _GUICtrlListView_InsertItem, _GUICtrlListView_AddItem, etc: the UDF functions.If you created your listview and it's items with GUICtrlCreateListView and GUICtrlCreateListViewItem, then you must manually delete all the items with GUICtrlDelete. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
GaryFrost Posted November 27, 2007 Share Posted November 27, 2007 _GUICtrlListView_GetSelectedCount(GUICtrlGetHandle($Hotfix_lv)) If you read the help file, when you create a new control, in most cases, it but not the handle Therefore you need to use GUICtrlGetHandle to retrieve the handle to work with the new UDF. Pretty much everything but the deletes can use a control id, if you use a control id in the deletes you'll get the error that I put in. Shouldn't be that hard to write your own wrapper to delete all the items of the control where they are created with the built-in function. 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...
benners Posted November 27, 2007 Author Share Posted November 27, 2007 Thanks for the replies, I read the ChangeLog.txt in the includes folder (never noticed that before) and it states a handle is now required so I have used the code by Generator 11/22/2007: Fixed: _GUICtrlListView_DeleteAllItems deleting listiview, handle now required (GaryFrost) Link to comment Share on other sites More sharing options...
Tweaky Posted December 2, 2007 Share Posted December 2, 2007 (edited) To summarize: Do not use _GUICtrlListView_DeleteAllItems() UNLESS you created the ListView and it's items with _GUICtrlListView_Create, _GUICtrlListView_InsertItem, _GUICtrlListView_AddItem, etc: the UDF functions.If you created your listview and it's items with GUICtrlCreateListView and GUICtrlCreateListViewItem, then you must manually delete all the items with GUICtrlDelete.I have create a listview with "GUICtrlCreateListView"I add the items with "GUICtrlCreateListViewItem"And to delete alle items I use "_GUICtrlListView_DeleteAllItems(ControlGetHandle("", "", $listview))"And it works fine.But why shouldn`t I use it???Are there any problems, or will "GUICtrlCreateListView" in next versions not be supportet???What is better at "_GUICtrlListView_Create" ???Thanks Edited December 2, 2007 by Tweaky Link to comment Share on other sites More sharing options...
smashly Posted December 2, 2007 Share Posted December 2, 2007 I have create a listview with "GUICtrlCreateListView" I add the items with "GUICtrlCreateListViewItem" And to delete alle items I use "_GUICtrlListView_DeleteAllItems(ControlGetHandle("", "", $listview))" And it works fine. But why shouldn`t I use it??? Are there any problems, or will "GUICtrlCreateListView" in next versions not be supportet??? What is better at "_GUICtrlListView_Create" ??? ThanksIn your scenario going by what I've read in the forums so far then maybe you'd be better off using GUICtrlDelete() as already stated by Gary. Myself I was using "_GUICtrlListView_DeleteAllItems(ControlGetHandle("", "", $listview))" to delete all internally added listview items without any probs for my needs. But I decided to follow the advice I read because there are more then likely problems that may occure in differant scenarios. When I create treeview items internally and I want to delete them all I've opted to use ..Do GUICtrlDelete(_GUICtrlListView_GetItemParam("listview", 0)) Until _GUICtrlListView_GetItemCount("listview") = 0 Cheers 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