dcsimg
September 19, 2020
Hot Topics:

VB TIP: Using Header Track Selection in a Listview

  • By Sam Huggill
  • Send Email »
  • More Articles »
Public Declare Function SendMessageByLong _
     Lib "user32" _
 Alias "SendMessageA" (ByVal hwnd As Long, _
              ByVal wMsg As Long, _
              ByVal wParam As Long, _
              ByVal lParam As Long) As Long

Public Declare Function GetWindowLong _
    Lib "user32" _
 Alias "GetWindowLongA" (ByVal hwnd As Long, _
                 ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong _
   Lib "user32" _
 Alias "SetWindowLongA" (ByVal hwnd As Long, _
              ByVal nIndex As Long, _
              ByVal dwNewLong As Long) As Long

Public Const LVM_FIRST As Long = &H1000
Public Const LVM_GETHEADER = (LVM_FIRST + 31)
Public Const GWL_STYLE = -16&
Public Const HDS_HOTTRACK = &H4

Private Sub HeaderTrackSelect(lv As ListView)
    Dim lngHwnd As Long
    Dim lngStyle As Long

    lngHwnd = SendMessageByLong(lv.hwnd, _
                                LVM_GETHEADER, _
                                0, 0)
    If lngHwnd <> 0 Then
        lngStyle = GetWindowLong(lngHwnd, GWL_STYLE)
        lngStyle = lngStyle Or HDS_HOTTRACK
        SetWindowLong lngHwnd, GWL_STYLE, lngStyle
    End If
End Sub





This article was originally published on November 19, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.


Thanks for your registration, follow us on our social networks to keep up-to-date