不知道我的例子能不能得到你的100分也,呵呵。
不要意思,代码我没有整理,放到窗体中,在窗体中加一个Listview就行。//////////////////////////////////////////////////////////////
////////代码行////////////////////////////////////////
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 Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal Y As Long, ByVal CX As Long, _
ByVal CY As Long, ByVal wFlags As Long) As LongConst GWL_STYLE = (-16)Private Const LVM_FIRST = &H1000Private Const LVM_GETHEADER = _
(LVM_FIRST + 31)
Private Const HDS_BUTTONS = &H2
Private Const SWP_DRAWFRAME = &H20
Private Declare Function SendMessageLong Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long'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 SetWindowPos Lib "user32" _
' (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
' ByVal x As Long, ByVal Y As Long, ByVal CX As Long, _
' ByVal CY As Long, ByVal wFlags As Long) As Long'Const GWL_STYLE = (-16)'Private Const LVM_FIRST = &H1000'Private Const LVM_GETHEADER = _
(LVM_FIRST + 31)
'Private Const HDS_BUTTONS = &H2
'Private Const SWP_DRAWFRAME = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_FLAGS = SWP_NOZORDER _
Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
Public Sub LV_FlatHeaders(hWndParent As Long, _
hWndListView As Long) Dim R As Long, Style As Long, hHeader As Long
hHeader = SendMessageLong(hWndListView, _
LVM_GETHEADER, 0, ByVal 0&)
Style = GetWindowLong(hHeader, GWL_STYLE)
Style = Style Xor HDS_BUTTONS
If Style Then
R = SetWindowLong(hHeader, GWL_STYLE, Style)
R = SetWindowPos(hWndListView, hWndParent, _
0, 0, 0, 0, SWP_FLAGS)
End If
End Sub
Private Sub Form_Load()
With ListView1
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "名称", 1900
.ColumnHeaders.Add , , "大小", 1300, lvwColumnCenter
.ColumnHeaders.Add , , "创建日期", 1500, lvwColumnCenter
.ColumnHeaders.Add , , "创建时间", 1500, lvwColumnCenter
.View = lvwReport
End With
Call LV_FlatHeaders(Me.hWnd, ListView1.hWnd)End Sub
不要意思,代码我没有整理,放到窗体中,在窗体中加一个Listview就行。//////////////////////////////////////////////////////////////
////////代码行////////////////////////////////////////
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 Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal Y As Long, ByVal CX As Long, _
ByVal CY As Long, ByVal wFlags As Long) As LongConst GWL_STYLE = (-16)Private Const LVM_FIRST = &H1000Private Const LVM_GETHEADER = _
(LVM_FIRST + 31)
Private Const HDS_BUTTONS = &H2
Private Const SWP_DRAWFRAME = &H20
Private Declare Function SendMessageLong Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long'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 SetWindowPos Lib "user32" _
' (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
' ByVal x As Long, ByVal Y As Long, ByVal CX As Long, _
' ByVal CY As Long, ByVal wFlags As Long) As Long'Const GWL_STYLE = (-16)'Private Const LVM_FIRST = &H1000'Private Const LVM_GETHEADER = _
(LVM_FIRST + 31)
'Private Const HDS_BUTTONS = &H2
'Private Const SWP_DRAWFRAME = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_FLAGS = SWP_NOZORDER _
Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
Public Sub LV_FlatHeaders(hWndParent As Long, _
hWndListView As Long) Dim R As Long, Style As Long, hHeader As Long
hHeader = SendMessageLong(hWndListView, _
LVM_GETHEADER, 0, ByVal 0&)
Style = GetWindowLong(hHeader, GWL_STYLE)
Style = Style Xor HDS_BUTTONS
If Style Then
R = SetWindowLong(hHeader, GWL_STYLE, Style)
R = SetWindowPos(hWndListView, hWndParent, _
0, 0, 0, 0, SWP_FLAGS)
End If
End Sub
Private Sub Form_Load()
With ListView1
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "名称", 1900
.ColumnHeaders.Add , , "大小", 1300, lvwColumnCenter
.ColumnHeaders.Add , , "创建日期", 1500, lvwColumnCenter
.ColumnHeaders.Add , , "创建时间", 1500, lvwColumnCenter
.View = lvwReport
End With
Call LV_FlatHeaders(Me.hWnd, ListView1.hWnd)End Sub
SendMessageLong treSorts.hwnd, TVM_SETBKCOLOR, 0, MyTVBackColor
记得不要用 SendMessage 而是 SendMessageLong。不知道ListView可以不,你试试在 APIVIEW 里找有没有设置颜色的常量,就象上面 TVM_SETBKCOLOR 一样
TO keanu_woo(爱老虎油) 我来TRY一下,如果行,稍后公布代码
LVM_SETBKCOLOR
LVM_SETBKCOLOR
wParam = 0;
lParam = (LPARAM) (COLORREF) clrBk; Sets the background color of a list view control. You can send this message explicitly or by using the ListView_SetBkColor macro. Returns TRUE if successful, or FALSE otherwise.
clrBk
Background color to set or the CLR_NONE value for no background color. List view controls with background colors redraw themselves significantly faster than those without background colors. 问题来了,怎么用啊??
Public Const LVM_FIRST = &H1000
Public Const LVM_SETBKCOLOR = (LVM_FIRST + 1)
不过好象用SENDMESSAGE后,没有任何变化!!!
自己绘制背景
最好发送LVM_GETHEADER消息得到ListView的Header的hWnd
LVM_GETHEADER
LVM_GETHEADER
wParam = 0;
lParam = 0;Retrieves the handle to the header control used by the list view control. You can send this message explicitly or use the ListView_GetHeader macro. Returns the handle to the header control.