I need to know what message is sent to my wndproc when the user selects an item in my list view control,
and how can I know which item was selected?

Cant figure it out, or find info. thanks

EDIT: I found it in the forums, you may remove this post =)
Posted on 2002-10-22 16:23:52 by david
david:

I recommend you to read the Iczelion's tutorial 31. You need to handle WM_NOTIFY:

"When we receive WM_NOTIFY message, lParam contains the pointer to an NMHDR structure. We can check if this message is from the listview control by comparing the hwndFrom member of NMHDR to the handle to the listview control. If they match, we can assume that the notification came from the listview control.

[...]

"If the notification is from the listview control, we check if the code is LVN_COLUMNCLICK. If it is, it means the user clicks on a column header. In the case that the code is LVN_COLUMNCLICK, we can assume that lParam contains the pointer to an NM_LISTVIEW structure which is a superset of the NMHDR structure. We then need to know on which column header the user clicks. Examination of iSubItem member reveals this info."
Posted on 2002-10-24 01:23:26 by n u M I T_o r
Thanks, yes it's working fine now




cmp uMsg, WM_NOTIFY
jnz _5
mov esi, lParam
assume esi:ptr NMHDR
cmp [esi].idFrom, IDC_LISTVIEW ; is notify msg from the listview
jnz _false
cmp [esi].code, LVN_ITEMCHANGED ; Did Something change
jnz _false
assume esi:ptr NM_LISTVIEW
mov eax, [esi].uNewState ; Has focus switched from one selection to another
cmp eax, LVIS_FOCUSED + LVIS_SELECTED
jnz _false
mov eax, [esi].iItem ; Get the "item number" of item in focus and display
invoke wsprintf, ADDR szBuffer, ADDR szFormat, eax ; szFormat : "iItem %lX"
Invoke MessageBoxA, hDlg, ADDR szBuffer, ADDR szNotify, MB_OK or MB_ICONEXCLAMATION

xor eax,eax
inc eax
ret

; NM_LISTVIEW STRUCT
; hdr NMHDR <>
; iItem DWORD ?
; iSubItem DWORD ?
; uNewState DWORD ?
; uOldState DWORD ?
; uChanged DWORD ?
; ptAction POINT <>
; lParam DWORD ?
; NM_LISTVIEW ENDS

Posted on 2002-10-24 15:47:55 by david