说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

将立体的ListView标题栏转换成平面式的标题栏 -VB资料

HTML文档下载 WORD文档下载 PDF文档下载
将立体的ListView标题栏转换成平面式的标题栏 -VB资料

当你想将你的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


备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘