also can use SubItemHitTest of the CListCtrl for functions like "OnLButtonDown" which don't have a struct passed (see Matt Parker's post below). You can check the definition of
LVHITTESTINFO struct in MSDN library.
If I use tab key and space bar to push the column
how can I detect the item number
how about selecting using ARROW KEYS?
Posted by Maverick5877
on 07/13/2005 05:53am
Maybe you have an idea about getting the selected column index using arrow keys...
i have problems on many ListCtrl events.. i.e.
void ...OnLvnItemchangedListService(NMHDR *pNMHDR, LRESULT *pResult)
LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR);
// pNMLV->subitem is always zero even if I have selected on
//columns other than the first one..
with OnNMClick().. subitem just works fine but
with all other event messages specially with the LVN_????() messages,
the subitem value of pNMHDR is not properly updated..
The latests version of the List Control allows user
to reorder columns with drag and drop when
the LVS_EX_HEADERDRAGDROP flag is set.
This HitTestEx function doesn't work properly for
such a reordered list control. Forunately the
fix pretty straightforward.
I've renamed the colnum variable to colpos to try
and be a little more clear.
I've changed the "for" loop to look at the columns
in the order they are currently sorted, not in
the order of their index.
I happen to know the maximum number of columns.
To be more general you could allocated an
array of size nColumnCount.
Here is the change to function:
HitTestEx(CPoint &point, int *col) const
// Now find the column
ASSERT( nColumnCount <= MAX_NUM_COLUMNS );
int aColumnOrder[ MAX_NUM_COLUMNS ];