PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: lvn_itemactivate  (Read 231 times)

Paul D. Elliott

  • Guest
lvn_itemactivate
« on: April 28, 2005, 02:52:06 PM »

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.

Code: [Select]

 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
Logged

Paul D. Elliott

  • Guest
lvn_itemactivate
« Reply #1 on: April 28, 2005, 03:26:13 PM »

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.

Code: [Select]

' 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
Logged

Roger Garstang

  • Guest
lvn_itemactivate
« Reply #2 on: April 28, 2005, 08:19:36 PM »

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.
Logged