CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Posts
    52

    Hot to detect detect item click in list control

    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.


  2. #2
    Join Date
    May 1999
    Posts
    13

    Re: Hot to detect detect item click in list control

    Try using LBN_SELCHANGE. It allows u to recieve a message when u click at an item in List Box


  3. #3
    Join Date
    Apr 1999
    Location
    Bangalore, India
    Posts
    25

    Re: Hot to detect detect item click in list control

    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.


  4. #4
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: Hot to detect detect item click in list control

    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.



    --
    Jason Teagle
    [email protected]

  5. #5
    Join Date
    Apr 1999
    Posts
    52

    Re: Hot to detect detect item click in list control

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured