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. CListCtrl Selection of Item Problem

CListCtrl Selection of Item Problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasehelpquestion
4 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.
  • A Offline
    A Offline
    Aamol M
    wrote on last edited by
    #1

    Problem- When I click on the empty space after any item or after all items then the current item selection goes away and I have no way to highlight previous item. (Though I have pervious selected item index). This is beacuse when item is selected MFC gives us two messages 1. Pervious Item Deselected. 2. Current item Selected. But when we click on empty area then 1) it gives message - Item Deselected ... and there is no other message again .... So we cant track whether you get 1 or 2 message from MFC.... This is all my perception about CListCtrl behaviour Does any one have a way to this problem???? Thanks in Advance :)

    AmolM

    G 1 Reply Last reply
    0
    • A Aamol M

      Problem- When I click on the empty space after any item or after all items then the current item selection goes away and I have no way to highlight previous item. (Though I have pervious selected item index). This is beacuse when item is selected MFC gives us two messages 1. Pervious Item Deselected. 2. Current item Selected. But when we click on empty area then 1) it gives message - Item Deselected ... and there is no other message again .... So we cant track whether you get 1 or 2 message from MFC.... This is all my perception about CListCtrl behaviour Does any one have a way to this problem???? Thanks in Advance :)

      AmolM

      G Offline
      G Offline
      GuyM
      wrote on last edited by
      #2

      You can catch the OnSelChangeListCtrl(...) and always keep the index of the previously selected item. Once you get that there is no selected item (when clicking under the last item) just call ListCtrl.SetItemState(PrevSelItem, LVIS_SELECTED, LVIS_SELECTED);

      A 1 Reply Last reply
      0
      • G GuyM

        You can catch the OnSelChangeListCtrl(...) and always keep the index of the previously selected item. Once you get that there is no selected item (when clicking under the last item) just call ListCtrl.SetItemState(PrevSelItem, LVIS_SELECTED, LVIS_SELECTED);

        A Offline
        A Offline
        Aamol M
        wrote on last edited by
        #3

        Sorry, but I didnt find any message like OnSelChangeListCtrl() for CListCtrl. I have captured 1) OnItemchangedList1() and 2) OnItemchangingList1() And the scenario was like the problem I posted.... I just can get the item selected or not :( Sequence of message is like 1) Previous item de-selected and 2) Current Item Selected ==> in case item is selected... Otherwise only 1st message.... if item is not selected (Clicked on empty area) Any Commments on this... Thanks for previous reply Thanks in Advance :)

        AmolM

        D 1 Reply Last reply
        0
        • A Aamol M

          Sorry, but I didnt find any message like OnSelChangeListCtrl() for CListCtrl. I have captured 1) OnItemchangedList1() and 2) OnItemchangingList1() And the scenario was like the problem I posted.... I just can get the item selected or not :( Sequence of message is like 1) Previous item de-selected and 2) Current Item Selected ==> in case item is selected... Otherwise only 1st message.... if item is not selected (Clicked on empty area) Any Commments on this... Thanks for previous reply Thanks in Advance :)

          AmolM

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

          Aamol M wrote:

          1. OnItemchangedList1() and

          Which is what GuyM was referring to as OnSelChangeListCtrl(). Whatever you are calling it, when the LVN_ITEMCHANGED notification is received, look at the uNewState member to see if it is LVNI_SELECTED. If so, save the item's value.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          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