FF_ListView_GetSelectedItem getting previous item

Started by Anonymous, March 21, 2006, 07:03:33 AM

Previous topic - Next topic

Anonymous

I have created a listview as a report style.
Each row is singularly selectable, and each time a row is selected with the cursor keys further information is given in a text box.
However, when i use the mouse to select a row, using the lbutton_up event, FF_ListView_GetSelectedItem returns the previous row, not the new row selected by the mouse click.
I notice that VB has a ItemClick event that does pick up the new row but this is not in the FF list.
Can anyone help?

TechSupport

Instead of struggling with the key up and mouse up handlers you should use the built in ListView notification that fires whenever the row changes.

Function FORM1_LISTVIEW1_LVN_ITEMCHANGED ( _
                                        ControlIndex  As Long,            _  ' index in Control Array
                                        hWndForm      As Dword,           _  ' handle of Form
                                        hWndControl   As Dword,           _  ' handle of Control
                                        ByVal lpNMV   As NM_LISTVIEW Ptr  _  ' pointer to NM_LISTVIEW
                                        ) As Long

  FF_Control_SetText HWND_FORM1_LABEL1, "Selected Row: " & Str$( @lpNMV.iItem )
 
End Function


Just look up the NM_LISTVIEW structure in your PB include files or search on MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/structures/nmlistview.asp

Hope this helps  :)

Anonymous

Thanks Paul.
I was actually already using this event but was also using the lbutton up event to capture mouse clicks. I simply removed the latter event and everything works fine.
Great, thanks again!