作者:绿色风
分类:
时间:2022-08-18
浏览:167
楼主 0Mouse |
Q:在VB中如何使Listview控件的标题行呈现平面效果,即如何将图1变成图2的效果呢? 图1:立体效果
立体效果.jpg 图2:平面效果
平面效果.jpg A:代码如下:
- Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
- (ByVal hwnd As Long, ByVal wMsg 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 Const GWL_STYLE = (-16)
- Private Const LVM_FIRST = &H1000
- Private Const LVM_GETHEADER = (LVM_FIRST + 31)
- Private Const HDS_BUTTONS = &H2
- Private Sub Form_Load()
- Dim Arr_Title, i&
- Arr_Title = Split("序号,姓名,语文,数学,英语", ",")
- With Lvw1
- For i = LBound(Arr_Title) To UBound(Arr_Title)
- .ColumnHeaders.Add , , Arr_Title(i), .Width / (UBound(Arr_Title) + 1)
- Next i
- End With
-
- Dim hHead As Long
- Dim style As Long
- '获取Listview控件标题行句柄
- hHead = SendMessage(Lvw1.hwnd, LVM_GETHEADER, 0, ByVal 0&)
- '获取标题行当前样式
- style = GetWindowLong(hHead, GWL_STYLE)
- '为标题行设置新的样式
- style = style Xor HDS_BUTTONS
- If style Then SetWindowLong hHead, GWL_STYLE, style
- End Sub
附件: 在VB中使Listview控件的标题行呈现平面效果.rar |
2楼 芐雨 |
学习了 |
3楼 水星钓鱼 |
感谢分享 |
免责声明
有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素,
经与ExcelTip.Net站长Apolloh商议并征得其同意,
现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示,
供有需要的人士查询使用,也慰缅曾经的论坛时代。
所示各个帖子的原作者如对版权有异议,
可与本人沟通提出,或于本站点留言,我们会尽快处理。
在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一