-
August 27th, 2017, 03:13 PM
#1
listview assistance
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);
}
}
}
-
August 28th, 2017, 02:43 AM
#2
Re: listview assistance
Did you try to handle the LVN_ITEMCHANGED notification?
Or you only need to process the selections made by keyboard?
Victor Nijegorodov
-
August 28th, 2017, 06:04 AM
#3
Re: listview assistance
Thank you VictorN.
This works for both clicks and key up/dn.
James
Code:
hListView = GetDlgItem( hWnd, IDC_LSV1);
lpnmhdr = ( LPNMHDR) lParam;
if(lpnmhdr->code == LVN_ITEMCHANGED )
{
iSelect = ListView_GetNextItem( hListView, - 1, LVNI_FOCUSED | LVNI_SELECTED);
if(iSelect > -1 )
{
strcpy(stemp, str(iSelect));
ZPRINT(stemp);
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|