VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 将立体的ListView标题栏转换成平面式的标题栏
发表评论(0)作者:, 平台:, 阅读:11083, 日期:2000-03-12
将立体的ListView标题栏转换成平面式的标题栏



当你想将你的ListView控件的标题栏变为平面式且对鼠标单击不做出反应的话,就

试试下面的代码吧。通常立体的标题栏会让用户认为这一栏的数据可以排序。如果

改成平面式的,用户就不会这样想了。


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 Declare Function SendMessage Lib "user32" Alias "SendMessageA" (

ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As

Any) 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