Hello,
I am working with the ListView control. I have a form setup that has a LV control and a textbox control. I have several items in the LV and I want the user to be able to click on one of the items in the LV control and have the text display in the textbox control. This is the code that I am using:
Function FRMCREATE_LVCREATEDFIELDS_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
Local sl As String
Local lIndex As Long
lIndex = FF_ListView_GetSelectedItem(HWND_FRMCREATE_LVCREATEDFIELDS)
FF_ListView_SetSelectedItem (HWND_FRMCREATE_LVCREATEDFIELDS,lIndex)
sl = FF_ListView_GetItemText (HWND_FRMCREATE_LVCREATEDFIELDS, lIndex , 0)
FF_TextBox_SetText HWND_FRMCREATE_TXTCREATEFIELD, sl
End Function
It does not appear to work properly. Can someone suggest a good way to achieve what I am after?
Thanks,
Noble
You need to access the members of the incoming NM_LISTVIEW to get the current ListView position during the LV_ITEMCHANGED message.
Try changing your code to the following:
Function FRMCREATE_LVCREATEDFIELDS_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
Local sl As String
Local lIndex As Long
lIndex = @lpNMV.iItem
sl = FF_ListView_GetItemText (HWND_FRMCREATE_LVCREATEDFIELDS, lIndex , 0)
FF_TextBox_SetText HWND_FRMCREATE_TXTCREATEFIELD, sl
End Function
Yep. That did the trick. Just curious, where can I find doc's on that? In a Windows API file?
nb
Yes, browse through the old Win32 api help file. It has sections on all the basics. It is not a hard read. PowerBASIC still has a copy of the help file: http://www.powerbasic.com/support/downloads/files/Win32API.zip