MFC項目用到CListCtrl控件,CListCtrl控件的view設置為list,而且style含有LVS_EX_CHECKBOXES,即每一行最前面都有一個checkbox,那麼問題來了,我在勾選和取消checkbox時,怎麼捕獲checkbox的change消息
void CStatusBarDlg::OnClickStateList(NMHDR* pNMHDR, LRESULT* pResult)
{
DWORD dwPos = GetMessagePos();
CPoint point( LOWORD(dwPos), HIWORD(dwPos) );
m_StatusList.ScreenToClient(&point);
LVHITTESTINFO lvinfo;
lvinfo.pt = point;
lvinfo.flags = LVHT_ABOVE;
UINT nFlag;
int nItem = m_StatusList.HitTest(point, &nFlag);
//判斷是否點在checkbox上
if(nFlag == LVHT_ONITEMSTATEICON)
{
TRACE("You click CheckBox,Item will be Clicked!");
}
*pResult = 0;
}