Reputation: 445
I've implemented a ListView control with LVS_EX_CHECKBOXES | LVS_EX_INFOTIP
style. I've registered function to get notified from list view control items using.
BEGIN_MESSAGE_MAP(Class, ParentClass)
ON_NOTIFY(LVN_GETINFOTIP,IDC_LIST2,OnClickCheckBox)
END_MESSAGE_MAP()
My question is, what notification code will be sent to parent when you select/de-select the checkbox in the item of ListView control..
What code need to be written to handle checkbox selection in the OnClickCheckBox() function ?
Kindly Help me
Upvotes: 4
Views: 1743
Reputation: 3636
You get the item-changed-message and you have to find out, if the checkbox-state has been changed.
In the message map:
ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, &CMyListView::OnLvnItemchanged)
Event handler:
void CMyListView::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
if(pNMLV->uNewState == 8192) // Item checked
{
...
}
else if(pNMLV->uNewState == 4096) // Item unchecked
{
...
}
*pResult = 0;
}
Upvotes: 1