Get the notification code from Listview Control checkboxes

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 21:12:36

问题


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


回答1:


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;
}


来源:https://stackoverflow.com/questions/13606686/get-the-notification-code-from-listview-control-checkboxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!