How and where do I put the code to find which line got clicked in a
ListView? I'm still learning but frankly the people here are much better
than the help files.
I tried putting it under the form_Custom in a Case based on wMsg but
it doesn't seem to be working. It might go in a case of WM_Notify but
that's as far as I got. I get a lot of the #2 messages.
Select Case wMsg
Case %LVN_ItemActivate
FF_Control_SetText HWND_SEARCH_TSEARCHTEXT, "got it !"
Case %WM_Notify
If wParam = IDC_SEARCH_LVSEARCH Then
'FF_Control_SetText HWND_SEARCH_TSEARCHTEXT, "got it #2 !"
End If
End Select
Never mind ( unless someone sees something dreadfully wrong with
the following code ). found it somewhat buried on source code by
Michael Mattias. I put it under the form_Custom routine.
' UNION used to handle the various types of pointers returned by WM_NOTIFY
Union LvUnion
NMHDR As NMHDR
NMLV As NMLISTVIEW
NMIA As NMITEMACTIVATE
LVDI As LV_DISPINFO
LVCD As NMLVCUSTOMDRAW
End Union
Local plvu As LvUnion Ptr
Local itm As Long
Select Case wMsg
Case %WM_Notify
plvu = lparam
Select Case @plvu.nmhdr.idfrom
Case IDC_SEARCH_LVSEARCH
Select Case @plVU.nmhdr.code
Case %LVN_ITEMACTIVATE ' right ?
itm = FF_ListView_GetSelectedItem(HWND_SEARCH_LVSEARCH)
FF_Control_SetText HWND_SEARCH_TSEARCHTEXT, "got it #2 ! >>" & Str$(itm)
End Select
End Select
End Select
I use LVM_HITTEST and pass it the point value of the mouse message (Whichever you want to activate it Left, Right, or the Double Clicks, etc.)
%LVM_GETNEXTITEM with %LVNI_FOCUSED Or %LVNI_SELECTED also works, but to me it seems slower to scan the whole list vs. checking what item is under the mouse.