News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

List View quirk

Started by hutch--, March 06, 2006, 06:58:13 AM

Previous topic - Next topic

hutch--

Donkey,

Thanks, for the test piece I wanted the LVM_HITTEST method as the task I had in mind was mouse based. Using the lht.pt structure is a good idea that saves the extra code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

Hi Hutch,

My pleasure. I generally only use the HITTEST to ensure that the user has actually clicked on an item then determine the item number using GETNEXTITEM. Otherwise the routine is called for any click inside the listview and if you set it to retain the focus using GETNEXTITEM will return the wrong item number. The example I posted is the most reliable way I have found to determine if first - the user actually selected an item and second - what the item number is. Every other way I attempted to solve this issue had it's own particular quirks.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

farrier

In my WM_NOTIFY handler, this handles sort--thanks to donkey--,Enter Key, Single Click, and Double Click to process ListView line with focus, or line Clicked or DoubleClicked.



wmnotify:
.else
mov eax, NMHDR.hwndFrom ;NMHDR.hwndFrom
.if eax, e, [hList]
.if NMHDR.code, e, LVN_COLUMNCLICK
.if NM_LISTVIEW.iSubItem, e, 1
;sort listview here
.endif
.elseif NMHDR.code, e, LVN_KEYDOWN
.if NMLVKEYDOWN.wVKey, e, VK_RETURN
jmp .display_line
.endif
.elseif NMHDR.code, e, NM_CLICK
jmp .display_line
.elseif NMHDR.code, e, NM_DBLCLK
jmp .display_line
.endif
.endif
.endif
jmp .finish
.display_line:
invoke SendMessage, [hList], LVM_GETNEXTITEM, -1, LVNI_FOCUSED ;find the item that has the focus, was clicked on
mov [.lvi.iItem], eax
mov [.lvi.iSubItem], 0
mov [.lvi.imask], LVIF_TEXT
lea eax, [.buffer]
mov [.lvi.pszText], eax
mov [.lvi.cchTextMax], 256
lea eax, [.lvi]
invoke SendMessage, [hList], LVM_GETITEM, 0, eax ;gets info from listview


farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)