c++ - How to react to LVN_ITEMCHANGED notification only when user finishes selecting action on multipe selection CListCtrl? -
i have dialog 2 list controls , 1 custom control graphic preview.
the first has list of 1 kind of entities (1a, 1b, 1c,...) , second has list of kind of entites (2a, 2b, 2c,...), both of them multi-select.
i want allow user select set of entities highlighted on preview, list last selection has been made.
for example:
- select 1a,1b,1c -> highlight them on preview
- select 2a,2b,2c -> unhighlight 1a,1b,1c , highlight 2a,2b,2c
if process each lvn_itemchanged
notification, preview flickering, want paint preview when user finishes selection function this:
void cpreviewpage::paintselection(hwnd hwnd) { m_preview.deselectall(); selectarray select; if(hwnd == m_lstfirst.getsafehwnd()) { for(int = 0; < m_lstfirst.getitemcount(); i++) { if( m_lstfirst.getitemstate(i, lvni_selected) & lvni_selected) { entity *pent = (entity *) m_lstfirst.getitemdata(i); select.append(pent); } } } else if(hwnd == m_lstsecond.getsafehwnd()) { for( int = 0; < m_lstsecond.getitemcount(); i++ ) { if( m_lstsecond.getitemstate(i, lvni_selected) & lvni_selected) { entity *pent = (entity *) m_lstsecond.getitemdata(i); select.append(pent); } } } m_preview.paintselect(&select); }
the problem is; when have 2a selected, hold shift , click 2c (to select 2a-2c), multiple lvn_itemchanged
, can't detect of them last. if could, possible repaint preview @ right moment, when user finishes his/her selecting action.
i tried call repaint function when lvni_focused
:
void cpreviewpage::onlstsecondselchanged(nmhdr *pnmhdr, lresult *presult) { nm_listview* pnmlistview = (nm_listview*) pnmhdr; if((pnmlistview->uchanged & lvif_state) && (pnmlistview->unewstate & lvni_focused) ) paintselection(pnmhdr->hwndfrom); }
however, lvni_focused
isn't guaranteed last, , don't want add button call paintselection
function.
so question is: when right moment when have state of items set, according user selection can call paintselection
?
Comments
Post a Comment