|
-
May 21st, 1999, 08:54 AM
#1
Detecting which subitem has been clicked in a listcontrol
I'm using VC++ 5.0, and I need to detect which subitem has been clicked in a list control. The method HitTest() only returns the item. A Method would be to test in which subitem range the click fall into but there is no way to get the listctrl position (GetOrigin() does not work in report mode).
So how do you detect the subitem on which the user click ?
-
May 21st, 1999, 09:33 AM
#2
Re: Detecting which subitem has been clicked in a listcontrol
A solution that works in alone or multiple selection mode:
int length = m_list.GetItemCount();
for (int i = 0; i < length;i++) {
if (m_list.GetItemState(i, LVIS_SELECTED)) {
// do what you want with the selected line
// use the index i for access to the object
// example: m_list.GetItemText( i, 0, szDest, 16 );
}
}
There is another solution for the one-select mode, but I've forgotten it. This one works well.
Pascal.
-
May 21st, 1999, 09:53 AM
#3
Re: Detecting which subitem has been clicked in a listcontrol
when you catch the OnClick event, you get a NMHDR* var as one of your parameters, you can cast this to a NM_LISTVIEW*, and it has an iSubItem member that should tell you which subitem was clicked (I think).
something like
void
CMyListCtl::OnClick (NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
int iSubItem = pNMListView->iSubItem;
}
--michael
-
May 21st, 1999, 09:54 AM
#4
Re: Detecting which subitem has been clicked in a listcontrol
Hello!
You can use method CListCtrl::SubItemHitTest() if you are using comctl32.dll version >= 4.70 (it comes with IE3.0). See MSDN for details.
Dmitry Barashev.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|