Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDetect when the user scrolls a ListView control
DescriptionThis example shows how to detect when the user scrolls a ListView control in Visual Basic 6.
KeywordsListView, scroll, detect
CategoriesControls, API
 
This program subclasses the ListView control. When the new WindowProc sees the WM_VSCROLL message, it calls the from's ListViewScrolled subroutine.
 
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg _
    As Long, ByVal wParam As Long, ByVal lParam As Long) As _
    Long
Const WM_NCDESTROY = &H82
Const WM_VSCROLL = &H115

    ' If we're being destroyed,
    ' restore the original WindowProc.
    If msg = WM_NCDESTROY Then
        SetWindowLong _
            hwnd, GWL_WNDPROC, _
            OldWindowProc
    End If

    NewWindowProc = CallWindowProc( _
        OldWindowProc, hwnd, msg, wParam, _
        lParam)

    ' Look for the WM_VSCROLL message.
    If (msg = WM_VSCROLL) Then
        ' Tell the form.
        Form1.ListViewScrolled
    End If
End Function
 
Subroutine ListViewScrolled displays the topmost item's text in the form's caption.
 
' The user has scrolled the ListView.
Public Sub ListViewScrolled()
Dim top_item As ListItem

    Set top_item = ListView1.GetFirstVisible
    Me.Caption = _
        top_item.Text & _
        ", " & top_item.SubItems(1) & _
        ", " & top_item.SubItems(2)
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated