Toggle Listview Headers Between Flat and 3-D

Whenever you want a ListView control with flat, nonclickable headers, use this code to toggle the header style. Flat headers don’t give users the impression of sortability that 3-D headers do:

 Private Declare Function GetWindowLong Lib _	"user32" Alias "GetWindowLongA" (ByVal hWnd _	As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib _	"user32" Alias "SetWindowLongA" (ByVal hWnd _	As Long, ByVal nIndex As Long, ByVal _	dwNewLong As Long) As LongPrivate Const GWL_STYLE = (-16)Private Const LVM_FIRST = &H1000Private Const LVM_GETHEADER = (LVM_FIRST + 31)Private Const HDS_BUTTONS = &H2Call ToggleHeader(ListView1.hWnd)Private Sub ToggleHeader(lsvhWnd As Long)	Dim hHeader As Long, lStyle As Long	hHeader = SendMessage(lsvhWnd, _		LVM_GETHEADER, 0, ByVal 0&)	lStyle = GetWindowLong(hHeader, GWL_STYLE)	SetWindowLong hHeader, GWL_STYLE, lStyle Xor _		HDS_BUTTONSEnd Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: