Click to See Complete Forum and Search --> : Hot to detect detect item click in list control
Louis Daoust
May 20th, 1999, 06:17 PM
I need to detect when I click on an item in a list control. I mapped the NM_CLICK notify message of the list control but this message is sent only if I release the mouse button over the item I clicked. I need to receive a message when I first click down on the item, at this point the item is already selected.
Sangeeta
May 21st, 1999, 01:17 AM
Try using LBN_SELCHANGE. It allows u to recieve a message when u click at an item in List Box
Vicky
May 27th, 1999, 02:03 AM
A click means the mouse button is pressed and then released. If you want to detect the item on which the mouse button was pressed there are two ways(if I remember correctly)
First, if you have a derived the view class from CListView, you can trap LButtonDown. This is the easiest way.
Second, if you have a CListCtrl in say, CFormView, you have to subclass. Relevent info is available in MSDN help.
Third, (I know I mentioned 2 but I am not sure about this) you can manually add the handler for LButtonDown and appropriate entry in the message map.
Hope this solve your problem.
Jason Teagle
May 27th, 1999, 02:36 AM
Try the LVN_ITEMCHANGING notification. That may work when you first put the button down, but it may only work if you are moving to a different item than the current, so if you put the mouse down on the currently-selected item you would not know.
Louis Daoust
May 27th, 1999, 08:59 AM
Thanks to you all who responded.
The final solution I adopted is by checking the LVN_ITEMCHANGED notify message (thanks to Jason Teagle for the hint about using LVN_ITEMCHANGING)By using this message and the content of the NM_LISTVIEW stuctured that is passed along I can determine if a new item has been selected by checking the LVIS_SELECTED state of the new and old states.
Thanks again.
Louis.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.