The List Control is defined as Single Selection on the resources.
Question 1
I want to have a checkbox on the header of first column of my <
Insert the column headers first. Then change the HDF_CHECKBOX
. For example:
m_list.SetExtendedStyle(LVS_EX_CHECKBOXES| LVS_EX_FULLROWSELECT);
CHeaderCtrl &header = *m_list.GetHeaderCtrl();
header.ModifyStyle(0, HDS_CHECKBOXES);
m_list.InsertColumn(0, L"Column0", 0, 120, 0);
m_list.InsertColumn(1, L"Column1", 0, 80, 1);
m_list.InsertColumn(2, L"Column2", 0, 80, 2);
HDITEM hdi = { 0 };
hdi.mask = HDI_FORMAT;
header.GetItem(0, &hdi);
hdi.fmt |= HDF_CHECKBOX;
header.SetItem(0, &hdi);
m_list.InsertItem(m_list.GetItemCount(), L"C0", 0);
m_list.InsertItem(m_list.GetItemCount(), L"C1", 0);
m_list.SetCheck(0, 1);
m_list.SetCheck(1, 1);
When handling the notification you can use the GetCheck
method to see if item is checked or not. Example:
if(pNMListView->uChanged & LVIF_STATE)
{
if(pNMListView->uNewState & LVIS_SELECTED)
{
...
}
else if(pNMListView->uNewState & LVIS_STATEIMAGEMASK && pNMListView->iItem >= 0)
{
if(m_list.GetCheck(pNMListView->iItem))
TRACE("%d checked\n", pNMListView->iItem);
}
}