Handling ListView Clicks

This is a discussion on Handling ListView Clicks within the Windows Programming forums, part of the Platform Specific Boards category; How can i know if my ListView has a item that have been clicked? Subclassing? If it is subclassing how ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    Handling ListView Clicks

    How can i know if my ListView has a item that have been clicked? Subclassing? If it is subclassing how can i subclass a windows that i did editing a resource?

    Thank you

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Handling a click is very similar to handling a right click. Here is some sample code. This code goes in the parent's window procedure.
    Code:
    case WM_NOTIFY:
    	lpnmhdr = (LPNMHDR)lParam;
    
    	if(lpnmhdr->hwndFrom == hwndList)
    	{
    		if(lpnmhdr->code == NM_CLICK)
    		{
    			LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
    			LVHITTESTINFO    hti      = { 0 };
    
    			hti.pt = lpnmitem->ptAction;
    			ListView_HitTest(hListView, &hti);
    
    			if(hti.flags & LVHT_ONITEM)
    			{
    				TCHAR buf[100];
    				wsprintf(buf, TEXT("Item No. %d was clicked."), hti.iItem);
    				MessageBox(NULL, buf, NULL, 0);
    			}
    		}
    	}
    	break;

  3. #3
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220
    Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. signal handling and exception handling
    By lehe in forum C++ Programming
    Replies: 2
    Last Post: 06-15-2009, 11:01 PM
  2. event handling is serialized in MS Visual Studio C++ 2005 ??
    By mynickmynick in forum Windows Programming
    Replies: 3
    Last Post: 08-07-2008, 05:47 AM
  3. Replies: 6
    Last Post: 07-10-2006, 01:05 AM
  4. Troubles with ListView and Toolbar
    By cornholio in forum Windows Programming
    Replies: 8
    Last Post: 11-14-2005, 01:26 AM
  5. Listview??
    By SuperNewbie in forum C# Programming
    Replies: 4
    Last Post: 02-13-2003, 03:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21