I am trying to get the current selection of a listview in report mode when the selection is created with the up and down arrow keys.
I am able to get the selection fine with a mouse click but can't figure out how to do it when the selection is changed using the keyboard
ZPRINT is a debuging utility I use:
https://www.codeproject.com/Articles...e-for-bit-only
---------------------------------------------------
str is library code returning the string representation of a number
------------------------------------------------------------------------------
I am only testing so using only the up and down arrow keys so no code to determine
the actual key is presented.
James
Code:
if(Msg == WM_NOTIFY )
{
if(LOWORD(wParam) == IDC_LSV1 )
{
hListView = GetDlgItem( hWnd, IDC_LSV1);
lpnmhdr = ( LPNMHDR) lParam;
if(lpnmhdr->code == NM_CLICK )
{
iSelect = ListView_GetNextItem( hListView, - 1, LVNI_FOCUSED);
strcpy(stemp, str(iSelect));
ZPRINT(stemp);
}
else if(lpnmhdr->code == LVN_KEYDOWN )
{
iSelect = ListView_GetNextItem( hListView, - 1, LVNI_SELECTED);
strcpy(stemp, str(iSelect));
ZPRINT(stemp);
}
}
}