Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. list view / how do i get a list of all selected items?

list view / how do i get a list of all selected items?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sebastian Pipping
    wrote on last edited by
    #1

    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

    J D 2 Replies Last reply
    0
    • S Sebastian Pipping

      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

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      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!)

      S 1 Reply Last reply
      0
      • S Sebastian Pipping

        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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • J James R Twine

          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!)

          S Offline
          S Offline
          Sebastian Pipping
          wrote on last edited by
          #4

          thanks for your quick reply! i overlooked LVM_FINDITEM somehow... DavidCrow suggested LVM_GETNEXTITEM instead: i compared these two and LVM_FINDITEM seems more powerful so expect more speed from LVM_GETNEXTITEM. also thanks for the tip on redrawing! ------------------------------------------- My website: http://www.hartwork.org

          1 Reply Last reply
          0
          • D David Crow

            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

            S Offline
            S Offline
            Sebastian Pipping
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups