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. How do I get the last LVN_ITEMCHANGED message?

How do I get the last LVN_ITEMCHANGED message?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
12 Posts 2 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.
  • H Offline
    H Offline
    hsuch
    wrote on last edited by
    #1

    Hi all, When I select or deselect multiple items on ListView control, I will get a lot of LVN_ITEMCHANGED messages. The problem is, how do I get the last one only, or how do I know it is the last one? I want to modify my data after it stop changing. Thanks for your help.

    D 1 Reply Last reply
    0
    • H hsuch

      Hi all, When I select or deselect multiple items on ListView control, I will get a lot of LVN_ITEMCHANGED messages. The problem is, how do I get the last one only, or how do I know it is the last one? I want to modify my data after it stop changing. Thanks for your help.

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

      Look for the one whose state is LVIS_SELECTED.


      "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

      H 1 Reply Last reply
      0
      • D David Crow

        Look for the one whose state is LVIS_SELECTED.


        "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

        H Offline
        H Offline
        hsuch
        wrote on last edited by
        #3

        Do you mean the information in NM_LISTVIEW structure? I have monitored the messages. Some previous messages also have this state on, and the last one doesn't always has this state either.

        D 1 Reply Last reply
        0
        • H hsuch

          Do you mean the information in NM_LISTVIEW structure? I have monitored the messages. Some previous messages also have this state on, and the last one doesn't always has this state either.

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

          hsuch wrote:

          Do you mean the information in NM_LISTVIEW structure?

          Yes.

          hsuch wrote:

          Some previous messages also have this state on...

          Which indicates your list control does not have the LVS_SINGLESEL style.


          "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

          H 1 Reply Last reply
          0
          • D David Crow

            hsuch wrote:

            Do you mean the information in NM_LISTVIEW structure?

            Yes.

            hsuch wrote:

            Some previous messages also have this state on...

            Which indicates your list control does not have the LVS_SINGLESEL style.


            "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

            H Offline
            H Offline
            hsuch
            wrote on last edited by
            #5

            Yes. It doesn't have the LVS_SINGLESEL style. That's why I think it is difficult to deal with. Right now I use a timer. I set a timer when I get the first message, after a short delay, I start to draw my window or something. If I handle each change message, my window will keep flashing during the processing. So I want to handle just once or in the last message. I'm looking for a better way to know when I get the last message. Thanks for your help.

            D 1 Reply Last reply
            0
            • H hsuch

              Yes. It doesn't have the LVS_SINGLESEL style. That's why I think it is difficult to deal with. Right now I use a timer. I set a timer when I get the first message, after a short delay, I start to draw my window or something. If I handle each change message, my window will keep flashing during the processing. So I want to handle just once or in the last message. I'm looking for a better way to know when I get the last message. Thanks for your help.

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

              In regards to your "I want to modify my data after it stop changing" comment, if some number of seconds elapse between selection messages, how are you to know if the subsequent selection is the last of the first group or the beginning of the next group? In other words, what defines "stop changing?" To get a better understanding of what you are trying to accomplish, what exactly are you doing with each selection in the list control?


              "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

              H 1 Reply Last reply
              0
              • D David Crow

                In regards to your "I want to modify my data after it stop changing" comment, if some number of seconds elapse between selection messages, how are you to know if the subsequent selection is the last of the first group or the beginning of the next group? In other words, what defines "stop changing?" To get a better understanding of what you are trying to accomplish, what exactly are you doing with each selection in the list control?


                "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

                H Offline
                H Offline
                hsuch
                wrote on last edited by
                #7

                I click one item in the list-view control, hold down shift key, click another item, then I can select the items between the first and the last one. After that, I draw selection lines in another window for those items to indicate they are selected. Because I know windows will produce a bundle of messages to notify this operation, I draw my window just once after these messages to get better performance. "stop changing" ==> windows won't generate selection messages anymore for this operation Depending on windows' behavior, if there are few seconds between the messages, it should be the next selection operation. I know it is the first of the next group since it comes after my last timer event.

                D 1 Reply Last reply
                0
                • H hsuch

                  I click one item in the list-view control, hold down shift key, click another item, then I can select the items between the first and the last one. After that, I draw selection lines in another window for those items to indicate they are selected. Because I know windows will produce a bundle of messages to notify this operation, I draw my window just once after these messages to get better performance. "stop changing" ==> windows won't generate selection messages anymore for this operation Depending on windows' behavior, if there are few seconds between the messages, it should be the next selection operation. I know it is the first of the next group since it comes after my last timer event.

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

                  hsuch wrote:

                  I click one item in the list-view control, hold down shift key, click another item, then I can select the items between the first and the last one.

                  This is the default behavior for a multiselect list control. Why are you having to intervene?


                  "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

                  H 1 Reply Last reply
                  0
                  • D David Crow

                    hsuch wrote:

                    I click one item in the list-view control, hold down shift key, click another item, then I can select the items between the first and the last one.

                    This is the default behavior for a multiselect list control. Why are you having to intervene?


                    "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

                    H Offline
                    H Offline
                    hsuch
                    wrote on last edited by
                    #9

                    Well, because my drawing function always draw all selected objects, even only one object changes the state. ><" I'm trying to decrease the overhead. My idea is to draw as less as possible. I google around and find some solutions like to set a timer or to add the owner-draw style. Maybe that's the way to go.

                    D 1 Reply Last reply
                    0
                    • H hsuch

                      Well, because my drawing function always draw all selected objects, even only one object changes the state. ><" I'm trying to decrease the overhead. My idea is to draw as less as possible. I google around and find some solutions like to set a timer or to add the owner-draw style. Maybe that's the way to go.

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

                      Do you have an owner-drawn control?


                      "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

                      H 1 Reply Last reply
                      0
                      • D David Crow

                        Do you have an owner-drawn control?


                        "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

                        H Offline
                        H Offline
                        hsuch
                        wrote on last edited by
                        #11

                        Sorry, the owner-drawn style also generates a lot of messages. But the LVS_OWNDERDATA style always generates 3 messages each operation. I have improved my timer logic and it works fine right now. Thanks for your help.

                        D 1 Reply Last reply
                        0
                        • H hsuch

                          Sorry, the owner-drawn style also generates a lot of messages. But the LVS_OWNDERDATA style always generates 3 messages each operation. I have improved my timer logic and it works fine right now. Thanks for your help.

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

                          So if you are not using an owner-drawn control, why are you having to draw anything selection-related? That is handled by the control itself.


                          "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