There are a few notifications based on what's happening.
If you are selecting an item and nothing is selected yet, you will get one LVIF_STATE change notification: uNewState & LVIS_SELECTED. The newly selected item will be found at:
pNMListView->iItem
If an item is selected before you select a new object, you'll get three state changes:
First you will be informed that the previous item in focus is losing focus:
pNMListView->uOldState & LVIS_FOCUSED
Then you will be notified that the old item is being unselected:
pNMListView->uOldState & LVIS_SELECTED
Finally, you will get the new item selection state:
pNMListView->uNewState & LVIS_SELECTED
(again look at iItem for newly selected item)
So the pitfall we ran across is that, because item deselection results in two notifications, we were doing a lot of repetitive, sometimes detrimental, processing. What we ended up doing was only doing this processing for the 2nd message (pNMListView->uOldState & LVIS_SELECTED), and skipping the same processing after the loss of focus notification.
'C / C++ / MFC' 카테고리의 다른 글
SendMessage C++ to C# using WM_COPYDATA (0) | 2015.06.16 |
---|---|
C++ 64비트 컨버팅 이슈 (0) | 2013.03.04 |
[MFC]디렉토리 유무 확인 (0) | 2012.08.20 |
CString to char * , char * to CString (0) | 2012.04.06 |