Always hard to find the correct topic title ;)
I have the following code to handle clicks in my Listview:
Works fine when you click on a Item in the Listview with the mouse. But I want also to handle selecting.
That means, "highlighting" of the Listview item should get handled as a click (so I can navigate with arrow keys through the items).
I think it's just another NM_* message, but I can't find wich :(
Thanks in advance,
bAZiK
I have the following code to handle clicks in my Listview:
.elseif uMsg == WM_NOTIFY
mov edi, lParam
assume edi:ptr NMHDR
mov eax, [edi].hwndFrom
.if eax == hListServer
.if [edi].code == NM_CLICK
invoke RtlZeroMemory, addr szBufferAddress, 32
invoke SendMessage, hListServer, LVM_GETNEXTITEM, -1, LVNI_FOCUSED
mov lvi.iItem, eax
mov lvi.iSubItem, 5
mov lvi.imask, LVIF_TEXT
mov eax, offset szBufferAddress
mov lvi.pszText, eax
mov lvi.cchTextMax, 32
invoke SendMessage, hListServer, LVM_GETITEM, 0, addr lvi
invoke SplitAddress, addr szBufferAddress
; unimportant code goes here
.endif
.endif
Works fine when you click on a Item in the Listview with the mouse. But I want also to handle selecting.
That means, "highlighting" of the Listview item should get handled as a click (so I can navigate with arrow keys through the items).
I think it's just another NM_* message, but I can't find wich :(
Thanks in advance,
bAZiK
NM_FIRST equ 0- 0
NM_LAST equ 0-99
NM_OUTOFMEMORY equ NM_FIRST-1
NM_CLICK equ NM_FIRST-2
NM_DBLCLK equ NM_FIRST-3
NM_RETURN equ NM_FIRST-4
NM_RCLICK equ NM_FIRST-5
NM_RDBLCLK equ NM_FIRST-6
NM_SETFOCUS equ NM_FIRST-7
NM_KILLFOCUS equ NM_FIRST-8
any of these help???
NM_LAST equ 0-99
NM_OUTOFMEMORY equ NM_FIRST-1
NM_CLICK equ NM_FIRST-2
NM_DBLCLK equ NM_FIRST-3
NM_RETURN equ NM_FIRST-4
NM_RCLICK equ NM_FIRST-5
NM_RDBLCLK equ NM_FIRST-6
NM_SETFOCUS equ NM_FIRST-7
NM_KILLFOCUS equ NM_FIRST-8
any of these help???
LVN_ITEMCHANGED
Hi,
Whoops, I see Comrade just answered the question, but here's my post anyway ;)
LVN_ITEMCHANGED or LVN_ITEMCHANGING will pick up arrow key movement in a regular listview. Both will pick up your mouse clicks as well (LVN_ITEMCHANGED only if a new item is selected). If you don't need to separate mouse vs arrow selections then you can probably use it for both.
If you are using a Virtual listview with the LVS_OWNERDATA style, LVN_ITEMCHANGED (only) will be sent when you mouse click on an item, but the arrow keys don't seem to work in a Virtual listview anyway. If need be you might be able to handle VK_DOWN/VK_UP and force a focus change to the next listview item. Hope this helps.
Cheers,
Kayaker
Whoops, I see Comrade just answered the question, but here's my post anyway ;)
LVN_ITEMCHANGED or LVN_ITEMCHANGING will pick up arrow key movement in a regular listview. Both will pick up your mouse clicks as well (LVN_ITEMCHANGED only if a new item is selected). If you don't need to separate mouse vs arrow selections then you can probably use it for both.
If you are using a Virtual listview with the LVS_OWNERDATA style, LVN_ITEMCHANGED (only) will be sent when you mouse click on an item, but the arrow keys don't seem to work in a Virtual listview anyway. If need be you might be able to handle VK_DOWN/VK_UP and force a focus change to the next listview item. Hope this helps.
Cheers,
Kayaker
.ELSEIF wmsg == WM_NOTIFY
mov edi,lparam
assume edi:ptr NMHDR
.if [edi].code == LVN_ITEMCHANGED
assume edi:ptr NM_LISTVIEW
;NM_LISTVIEW STRUCT
; hdr NMHDR <>
; iItem DWORD ?
; iSubItem DWORD ?
; uNewState DWORD ?
; uOldState DWORD ?
; uChanged DWORD ?
; ptAction POINT <>
; lParam DWORD ?
;NM_LISTVIEW ENDS
mov eax, [edi].uNewState
.if eax == LVIS_FOCUSED + LVIS_SELECTED
; DO WHATEVER
.endif