Jump to content

Get ListViewItem control handle


 Share

Recommended Posts

Can anyone suggest a function which would take a ListView handle and a ListViewItem index as parameters and return the ListViewItem control handle.

I need the handle because the functions GuiCtrlSetImage, GuiCtrlSetBkColor and GuiCtrlSetColor only accept a control handle as a parameter. So if I want to set an icon to a ListViewItem , or want to change its background color or foreground color; I need the control handle for the ListViewItem, NOT the ListViewItem index number.

Right now the only way of getting the handle for the ListViewItem is by storing the return value of GuiCtrlCreateListViewItem which return the handle for the ListViewItem being created.

The reason why the above approach is not feasible for me is that I have a separate function for adding the ListViewItems and a separate function for adding icons and background color of the ListViewItems. Moreover, the icons and background color are more related to the position index of the ListViewItem. For example, I want the first item in the ListView control to always have a Red background. Since I also have a button to remove items from the ListView, therefore which item becomes is the first item is not fixed.

If a script example is required, I can come up with one. However, if you understand my question, any suggestions to achieve this would be more than welcome.

Link to comment
Share on other sites

There is no handle for a listview item available (it's different to for instance a treeview item) !

Generally listview items are always controlled by it's index so it should be no problem.

Just take a look into the beta version _GUIListView-UDF's.

Regards ;)

Holger

Link to comment
Share on other sites

You mention that you use separate functions to create ListViewItems and another to manipulate them. I would suggest having your creating function return an array of item identifiers, which you could then pass as an argument to the manipulating function. If you initially add the identifiers sequentially into the array then the array indexes would correspond with the actual item indexes, which you could use to your advantage.

Edit: After re-reading your post I noticed talk of deleting items. You could write a function to do the dirty work which would be to delete the ListViewItem, and then appropriately update the array by removing the identifier in question and shifting the remaining values up to take its place.

Edited by LxP
Link to comment
Share on other sites

@LxP

Thanks for your suggestion. As you said, its possible to create an array to store the ListView Items identifiers (or as I prefer to call them: handles) and then manipulate the array to always reflect the true state of the ListView control Items. However, this approach is my last option. Is it possible to have a Win32 API Dll call or something similiar to return a list of the current ListView Items identifiers for a ListView control?

@Holger

There is no handle for a listview item available (it's different to for instance a treeview item) !

Generally listview items are always controlled by it's index so it should be no problem.

Just take a look into the beta version _GUIListView-UDF's.

Regards ;)

Holger

Ok, handles or ListView Item identifiers; whichever way you wish to call them. They are the ones which I need to pass as arguments to GuiCtrlSetImage or GuiCtrlSetBkColor to change the icon/background color for a List View Item. For this purpose having the index number of the ListView Item is of no use.

Can you suggest a way to get these idenfiers/handles of ListView Items from a ListView control without using GuiCtrlCreateListViewItem?

I guess there have been similiar posts before, differently worded, but this will solve many problems with ListView controls.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...