|
-
September 12th, 1999, 09:02 AM
#1
I get multiple LVN_ITEMCAHNGED notifications in CListCtrl derived class
I want to do something on every change of selection-set in a multi-select CListCtrl. I am handling the LVN_ITEMCHANGED notification but I get multiple LVN_ITEMCAHNGED notifications. I have been able to get help from the documentation. Which member of the NM_LISTVIEW do I need to use to filter amongst the multiple messages? Or is there another way to determine the selection change once?
Thanks in advance.
-
September 27th, 1999, 05:59 AM
#2
Re: I get multiple LVN_ITEMCAHNGED notifications in CListCtrl derived class
Hi!
I guess we are both solving the same problem. I can't find anything on Microsoft's documentation.It seems that we get a LVN_ITEMCHANGED notification everytime an item's state changes. Now, if you have a selected set of items and you want to change it to a different set of items you'll get the LVN_ITEMCHANGED notification messages for both the deselection and the selection. Now my code doesn´t work like i want it to work, but have you tried to verify the uOldState/uNewState of the NM_LISTVIEW structure and compare it with LVIS_SELECTED?
I'm using these NM_LISTVIEW members combined with the uChanged member.Like:
//Check for state changes
if(pNMListView->uChanged==LVIF_STATE)
{
//Is it selected?
if(pNMListView->uNewState==LVIS_SELECTED)
{
......
}
//Was it selected?
if(pNMListView->uOldState==LVIS_SELECTED)
{
......
}
}
Depending on what you want to do, this approach might help you. It almost helped me.
Let me know if it did or not.
Bye and good luck.
Lu*s Teixeira
-
January 6th, 2002, 12:47 AM
#3
Re: I get multiple LVN_ITEMCAHNGED notifications in CListCtrl derived class
I also have the same problem and this is what i found out.// When you first select an item in the list control
pNMListView->uNewState == LVIS_FOCUSED | LVIS_SELECTED;
/* --- Later when you select another item onwards, 3 selection changed notifications are sent --- */
// First notification
pNMListView->uNewState == 0;
pNMListView->uOldState == LVIS_FOCUSED;
// Second notofication
pNMListView->uNewState == 0;
pNMListView->uOldState == LVIS_SELECTED;
// Third notification
pNMListView->uNewState == LVIS_FOCUSED | LVIS_SELECTED;
pNMListView->uOldState == 0;
As a result, i did this on LVN_ITEMCHANGED to filter off those unneeded notifications// Check if item changed
if (pNMListView->uNewState == (LVIS_FOCUSED | LVIS_SELECTED) && pNMListView->uOldState == 0)
{
// Do my stuff
}
Chen Weiye
------------------------------------------------------------------------------
When pursuing your dream, don't forget to enjoy your life...
------------------------------------------------------------------------------
Chen Weiye
-----------------------------------------------------------------------------
When pursuing your dream, don't forget to enjoy your life
-----------------------------------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|