Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 13, 1999

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 Long
Private Declare Function SetWindowLong Lib _
	"user32" Alias "SetWindowLongA" (ByVal hWnd _
	As Long, ByVal nIndex As Long, ByVal _
	dwNewLong As Long) As Long

Private Const GWL_STYLE = (-16)
Private Const LVM_FIRST = &H1000
Private Const LVM_GETHEADER = (LVM_FIRST + 31)
Private Const HDS_BUTTONS = &H2

Call 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_BUTTONS
End Sub

Matt Hart
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

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