A couple of listview questions

Started by JR Heathcote, March 02, 2006, 12:03:35 PM

Previous topic - Next topic

JR Heathcote

In Firefly how do I determine if a particular row in a listview control is visible, or has been scrolled out of range?

How do I determine if the listview vertical scrollbar is visible or not?

TechSupport


Function FF_ListView_IsLineVisible( ByVal hWndControl As Dword, _
                                   ByVal nLineNum As Long _
                                   ) As Long

  If IsWindow( hWndControl) = 0 Then Exit Function
   
  Local nFirstLine    As Long
  Local nItemsPerPage As Long

  nFirstLine    = ListView_GetTopIndex( hWndControl )
  nItemsPerPage = ListView_GetCountPerPage( hWndControl )
   
  If ( nLineNum >= nFirstLine ) And _
     ( nLineNum <= nFirstLine + nItemsPerPage ) Then
     Function = %TRUE
  End If
                                                 
End Function


You can use the function ListView_EnsureVisible to ensure that a line of yours is made to be visible.

TechSupport

Not sure what the best way it is to check for the scroll bar visibility but you can try the following:

Function FF_ListView_IsScrollbarVisible( ByVal hWndControl As Dword ) As Long

  If IsWindow( hWndControl) = 0 Then Exit Function
   
  Local nItemCount    As Long
  Local nItemsPerPage As Long

  nItemCount    = ListView_GetItemCount( hWndControl )
  nItemsPerPage = ListView_GetCountPerPage( hWndControl )
   
  If ( nItemCount > nItemsPerPage ) Then
     Function = %TRUE
  End If
                                                 
End Function