list view / how do i get a list of all selected items?
-
i'm using plain winapi and i'm trying to find out which items are selected in a multi-selection listview window. i need this for "remove all selected items" functionality. (1) i could walk down all items and check if an item is selected. but that would take very long with big lists (linear time) (2) i could also track selection changes inside the window procedure but i guess this would slow down selecting/unselecting items noticebly. also it would be a lot of extra coding. isn't there some easy, fast and elegant way to get a list of all selected items? a listbox provides a message for this - listview does not? please help! thanks in advance, sebastian ------------------------------------------- My website: http://www.hartwork.org
-
i'm using plain winapi and i'm trying to find out which items are selected in a multi-selection listview window. i need this for "remove all selected items" functionality. (1) i could walk down all items and check if an item is selected. but that would take very long with big lists (linear time) (2) i could also track selection changes inside the window procedure but i guess this would slow down selecting/unselecting items noticebly. also it would be a lot of extra coding. isn't there some easy, fast and elegant way to get a list of all selected items? a listbox provides a message for this - listview does not? please help! thanks in advance, sebastian ------------------------------------------- My website: http://www.hartwork.org
My first guess would be to use
LVM_FINDITEM
to find selected items... Be sure to turn off redrawing during the delete operations to improve performance. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
i'm using plain winapi and i'm trying to find out which items are selected in a multi-selection listview window. i need this for "remove all selected items" functionality. (1) i could walk down all items and check if an item is selected. but that would take very long with big lists (linear time) (2) i could also track selection changes inside the window procedure but i guess this would slow down selecting/unselecting items noticebly. also it would be a lot of extra coding. isn't there some easy, fast and elegant way to get a list of all selected items? a listbox provides a message for this - listview does not? please help! thanks in advance, sebastian ------------------------------------------- My website: http://www.hartwork.org
Sebastian Pipping wrote:
i need this for "remove all selected items" functionality.
Make sure you delete from the bottom-up (e.g., largest item to the smallest item).
Sebastian Pipping wrote:
(1) i could walk down all items and check if an item is selected. but that would take very long with big lists (linear time)
Use the
LVM_GETNEXTITEM
message for this?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
-
My first guess would be to use
LVM_FINDITEM
to find selected items... Be sure to turn off redrawing during the delete operations to improve performance. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)thanks for your quick reply! i overlooked
LVM_FINDITEM
somehow... DavidCrow suggestedLVM_GETNEXTITEM
instead: i compared these two andLVM_FINDITEM
seems more powerful so expect more speed fromLVM_GETNEXTITEM
. also thanks for the tip on redrawing! ------------------------------------------- My website: http://www.hartwork.org -
Sebastian Pipping wrote:
i need this for "remove all selected items" functionality.
Make sure you delete from the bottom-up (e.g., largest item to the smallest item).
Sebastian Pipping wrote:
(1) i could walk down all items and check if an item is selected. but that would take very long with big lists (linear time)
Use the
LVM_GETNEXTITEM
message for this?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
thanks for you quick reply! i am using
LVM_GETNEXTITEM
now. i stumbled over the line "The specified item is itself excluded from the search" on MSDN, and modified my code so it works with top-down deletion:iWalk = SendMessage( _hView, LVM_GETNEXTITEM, iWalk - 1, LVNI_SELECTED );
------------------------------------------- My website: http://www.hartwork.org