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