|
-
November 25th, 2004, 07:08 PM
#1
List View Question (Win32)
Please use Win32 only, no MFC. Thank you.
Since I sort my items in my list view, it is pretty much impossible to use an item's index value to reference it, considering that an items index is based on its position in the list view, from top to bottom.
To compensate for this, I reference an item based on its lParam value in LVITEM struct. When I add an item, I configure the lParam item of the LVITEM structure with a unique value that I can use to reference the item, no matter what position it has in the list view.
The only problem is that most of the list view macros supplied by Windows API requires the index value of the item, not the lparam. Hence I need a function that can do one of the following:
1. A function that accepts an lParam value and returns the item's index value.
2. A function that accepts an lParam value and returns the item's LVITEM structure, which will contain the item's index AND lparam value, along with several other properties.
I hope someone can help me out, because I"ve been reading MSDN and I've come up with nothing helpful yet.
Thank you!
-
November 25th, 2004, 07:51 PM
#2
Re: List View Question (Win32)
Actually, it's the same in MFC but there you go.
Sorting is done on the data of each item... as you know.
To sort I tend to first load all the item's data into a map (if you're not using MFC then use STL instead).
Then set all the items data appropriately and run the sort.
Then put all the items data back to their original values.
Using a map this'll be about as efficient as you're going to get.
Darwen.
-
November 25th, 2004, 09:50 PM
#3
Re: List View Question (Win32)
I don't quite understand...
Could you explain further?
-
November 26th, 2004, 03:22 AM
#4
Re: List View Question (Win32)
-
November 26th, 2004, 04:28 AM
#5
Re: List View Question (Win32)
 Originally Posted by MrDoomMaster
Please use Win32 only, no MFC. Thank you.
Since I sort my items in my list view, it is pretty much impossible to use an item's index value to reference it, considering that an items index is based on its position in the list view, from top to bottom.
To compensate for this, I reference an item based on its lParam value in LVITEM struct. When I add an item, I configure the lParam item of the LVITEM structure with a unique value that I can use to reference the item, no matter what position it has in the list view.
The only problem is that most of the list view macros supplied by Windows API requires the index value of the item, not the lparam. Hence I need a function that can do one of the following:
1. A function that accepts an lParam value and returns the item's index value.
2. A function that accepts an lParam value and returns the item's LVITEM structure, which will contain the item's index AND lparam value, along with several other properties.
I hope someone can help me out, because I"ve been reading MSDN and I've come up with nothing helpful yet.
Thank you!
I think, the ListView_FindItem macro (or sending the message LVM_FINDITEM to your list control) is what you need. See MSDN for additional info...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|