Hi,
I'm just converting a ListBox into a ListView with FireFly.
With the ListBox I've got a LBN_DBLCLK message to process the user double-clicks :
Function FORM1_LIST1_LBN_DBLCLK ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idListBox As Dword _ ' identifier of listbox
) As Long
End Function
With the ListView, I understand that the equivalent would be the LVN_ITEMACTIVATE message, but there is no LVN_ITEMACTIVATE message handler to process this message in FireFly.
1. Is-there any workaround for this one ?
2. Paul can you provide a separate message handler for LVN_ITEMACTIVATE for the ListView control ?
Here is the way that I catch double-clicks in a ListView. I respond to the %NM_DBLCLK notification that gets sent to the parent window (i.e. the Form).
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_NOTIFY ( _
hWndForm As Dword, _ ' handle of Form
idCtrl As Dword, _ ' control ID
ByVal pNMHDR As NMHDR Ptr _ ' pointer to NMHDR structure
) As Long
'test to see if this is our ListView sending the message
Select Case As Long @pNMHDR.idfrom
Case IDC_FORM1_LISTVIEW1
'process the double-click notification message
If @pNMHDR.code = %NM_DBLCLK Then
'get the ListView row that was clicked on.
row& = FF_ListView_GetSelectedItem (HWND_FORM1_LISTVIEW1)
MsgBox " NM_DBLCLK on listview row:" & Str$(row&)
End If
End Select
End Function
Hi Paul,
Thank you for your help; I use your code and modify it to respond to %LVN_ITEMACTIVATE notifcation; it works very well.
I prefer to use the %LVN_ITEMACTIVATE instead %NM_DBLCLK because when the ListView is empty (no items in the ListView) :
%NM_DBLCLK still send a notifcation message and I don't need a message at that time.
%LVN_ITEMACTIVATE doesn't send a notification message, because there is no item selected in the ListView.
Function FORM1_WM_NOTIFY ( _
hWndForm As Dword, _ ' handle of Form
idCtrl As Dword, _ ' control ID
ByVal pNMHDR As NMHDR Ptr _ ' pointer to NMHDR structure
) As Long
'test to see if this is our ListView sending the message
Select Case As Long @pNMHDR.idfrom
Case IDC_FORM1_LISTVIEW1
'process the ListView Item Activate notification message
If @pNMHDR.code = %LVN_ITEMACTIVATE Then
'get the ListView row that was clicked on.
row& = FF_ListView_GetSelectedItem (HWND_FORM1_LISTVIEW1)
MsgBox " LVN_ITEMACTIVATE on listview row:" & Str$(row&)
End If
End Select
End Function