Hi, I have a form with three listviews. I am able to detect the click event on two of them (notification message to the form). The third listview is on a tab control. The form receives notification messages from this listview, but not the click notification. Does this go somewhere else? Where? Or is it impossible to detect a click event in a listview on a tab?
Any help is appreciated...
Wilko
Wilko,
Would it be possible for you to post a whittled down version in FF that demonstrates the problem? It would be a real help to be able to see what you have done. Otherwise we are left guessing about what your code looks like. It's pretty involved to try and whip one up from scratch.
Hi David and others,
This is the code, with some comments to make other members clear what my point is
RM_WM_NOTIFY ( _
hWndForm As Dword, _ ' handle of Form
idCtrl As Dword, _ ' control ID
ByVal pNMHDR As NMHDR Ptr _ ' pointer to NMHDR structure
) As Long
Local Col As Long
Local DwPos As Dword
Local hWndLV As Long
Local I As Long
Local LpLvNm As NM_LISTVIEW Ptr
Local P_Info As LV_HitTestInfo
Local Rc As Rect
Local Row As Long
Select Case @pNMHDR.idFrom
'filter the controls I am interested in
Case IDC_EDITINPUTFORM_LVCAT, IDC_EDITINPUTFORM_LVLIG, IDC_EDINPRED_LVRED
LpLvNm = pNMHDR
Select Case @LpLvNm.hdr.Code
Case %NM_CLICK 'left click
Select Case @pNMHDR.idFrom
Case IDC_EDITINPUTFORM_LVCAT
hWndLV = HWND_EDITINPUTFORM_LVCAT 'this one works
Case IDC_EDITINPUTFORM_LVLIG
hWndLV = HWND_EDITINPUTFORM_LVLIG 'this one works too
Case IDC_EDINPRED_LVRED
hWndLV = HWND_EDINPRED_LVRED 'this one is on tab and does not work
End Select
DwPos = GetMessagePos()
'first get screen position in screen coordinates
P_Info.pt.x = LOWORD(DwPos)
P_Info.pt.y = HIWORD(DwPos)
'convert to list-view coordinates
ScreenToClient(hWndLV, P_Info.pt)
'where hit?
ListView_SubItemHitTest(hWndLV, P_Info)
If P_Info.iItem = -1 Then 'first column
Col = 1 '1-based
For I = 0 To FF_ListView_GetItemCount(hWndLV)
ListView_GetItemRect(hWndLV, I, Rc, %LVIR_BOUNDS)
If Rc.nTop > P_Info.pt.y Then
Row = I
Exit For
End If
Next I
If Row = 0 Then Row = FF_ListView_GetItemCount(hWndLV)
Else 'second or further column
Col = P_Info.iSubItem + 1
Row = P_Info.iItem + 1
End If
Select Case @pNMHDR.idFrom
Case IDC_EDITINPUTFORM_LVCAT
Call HandleClickCations(Col, Row) '2 = conc, 3 = unit, 4 = type of inp value
Case IDC_EDITINPUTFORM_LVLIG
Call HandleClickLigands(Col, Row) '2 = conc, 3 = unit, 4 = type of inp value
Case IDC_EDINPRED_LVRED
Call HandleClickRedSols(Col, Row) '2 = conc, 3 = unit
End Select
End Select
End Select
End Function
OK, I got it. The click notification message is sent to the form which is the child form of the tab control. Strange that other notification messages go to the form where the tab control is...
Thanks anyway
Wilko
Glad you figured it out Wilko. No need now, but I was asking for a full blown FF project, with everything left out but the relevant code. That way, we would have some chance of helping you figure out why your code wasn't working as desired. :)
David