you can get the selected item sendig 'LVM_GETNEXTITEM' to the list control, setting the WPARAM as -1 and the LPARAM as 'LVNI_FOCUSED|LVNI_SELECTED' (there are other options for that); something like:
Code:
int i=-1;
i=SendMessage(listhwnd,LVM_GETNEXTITEM,(WPARAM)-1,(LPARAM)LVNI_FOCUSED|LVNI_SELECTED);
by default that returns -1 if there's any problem with the operation.
if you want to get the item on the 'onclick' event (also other events), you can do it getting the WM_NOTIFY message (procedure's UINT); from it 'filter' the list's id (proc's LOWORD(WPARAM)) and get the LPNMHDR structure (proc's LPARAM); from that struct check the 'code' (UINT) value (if you want the normal click check for the 'NM_CLICK', for the right click->NM_RCLICK, you can google for other events). now send a message to get the selected item, as before if the value is -1 that means that the user has clicked over the list control but no over an item, so exit the function. a basic:
Code:
case WM_NOTIFY:
{
switch(LOWORD(wParam))
{
case LISTIDENTIFYER:
{
switch(((LPNMHDR)lParam)->code)
{
case NM_CLICK:
{
int i=-1;
i==SendMessage(listhwnd,LVM_GETNEXTITEM,(WPARAM)-1,(LPARAM)LVNI_FOCUSED|LVNI_SELECTED);
if(i>=0)
{
//ok, you have selected an item
}
//close all brakets :)
hope that helps
Niara