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
 
 
 
 
 
TitleGive a ListView control flat headers
DescriptionThis example shows how to give a ListView control flat headers in Visual Basic 6. It uses the SetWindowLong API function to remove the HDS_BUTTONS style from the control.
KeywordsListView, header, flat header
CategoriesControls, Tips and Tricks
 
Thanks to Dipak Auddy.

Subroutine SetFlatHeaders uses SendMessage to get a handle to the ListView's header. It uses GetWindowLong to get the header's style, clears the HDS_BUTTONS style bit, and then uses SetWindowLong to set the header's new style.

 
' Give the ListView a flat header style.
Private Sub SetFlatHeaders(ByVal lvw As ListView)
Dim lv_hwnd As Long
Dim hHeader As Long
Dim Style   As Long

    ' Get the handle to the listview header
    lv_hwnd = lvw.hwnd
    hHeader = SendMessage(lv_hwnd, LVM_GETHEADER, 0, ByVal _
        0&)

    ' Set the new style
    Style = GetWindowLong(hHeader, GWL_STYLE)
    Style = Style And Not HDS_BUTTONS
    SetWindowLong hHeader, GWL_STYLE, Style
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated