CListView Vista Problem
We are modifying a CListView Control as follows:
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
...
DWORD dwAdd = LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS |
LVS_OWNERDATA;
DWORD dwRemove = LVS_TYPEMASK;
GetListCtrl().ModifyStyle(dwRemove, dwAdd);
ListView_SetExtendedListViewStyle(GetListCtrl().m_hWnd,
LVS_EX_FULLROWSELECT |
LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES |
LVS_EX_HEADERDRAGDROP | LVS_EX_CHECKBOXES);
CHeaderCtrl* pHeaderCtrl = GetListCtrl().GetHeaderCtrl();
ASSERT(pHeaderCtrl != NULL);
if (pHeaderCtrl != NULL)
{
DWORD dwAdd = HDS_HOTTRACK | HDS_BUTTONS | HDS_DRAGDROP | HDS_FULLDRAG;
DWORD dwRemove = 0;
pHeaderCtrl->ModifyStyle(dwRemove, dwAdd);
}
...
}
Our code handling the click of the CMyListView contains:
void CMyListView::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
int iItem;
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (!pNMListView->uOldState && !pNMListView->uNewState)
return;
// Process the click
...
}
When we use this control with the above custom code in Windows XP, Clicking
in the checkbox results in:
pNMListView->uOldState = 1031
pNMListView->uNewState = 0
and the rest of our code executes just fine.
When we use this control in Windows Vista, Clicking in the checkbox results
in:
pNMListView->uOldState = 0
pNMListView->uNewState = 0
and the rest of our code does not execute.
If I remove the check "if (!pNMListView->uOldState &&
!pNMListView->uNewState)", the code executes just fine, but I'd like to
understand why the values are different for XP and Vista before removing this
check.