vb,如何调整listview控件里的图标间距?
2个回答
2014-08-17
展开全部
‘VB中使用SendMessage 控制listview图标间距
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Const LVM_FIRST = &H1000
Const LVM_SETWORKAREA = LVM_FIRST + 65
Const LVM_SETICONSPACING = LVM_FIRST + 53
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 Sub Form_Load()
Dim xn As ListItem
Dim Rects As RECT
Dim i As Integer
ListView1.Arrange = lvwAutoLeft
ListView1.View = lvwIcon
Me.Show
For i = 100 To 110
ListView1.ListItems.Add , , i
Next
With Rects
.Left = 100
.Top = 100
.Right = ListView1.Width / Screen.TwipsPerPixelX
.Bottom = ListView1.Height / Screen.TwipsPerPixelX
End With
'下面这句用来控制区域
SendMessage ListView1.hwnd, LVM_SETWORKAREA, 1, Rects
'下面这句用来控制ListItem之间的距离,横向间距80像素,纵向间距50像素
Call SendMessage(ListView1.hwnd, LVM_SETICONSPACING, 0, ByVal (50 * 65536 + 80&))
End Sub
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Const LVM_FIRST = &H1000
Const LVM_SETWORKAREA = LVM_FIRST + 65
Const LVM_SETICONSPACING = LVM_FIRST + 53
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 Sub Form_Load()
Dim xn As ListItem
Dim Rects As RECT
Dim i As Integer
ListView1.Arrange = lvwAutoLeft
ListView1.View = lvwIcon
Me.Show
For i = 100 To 110
ListView1.ListItems.Add , , i
Next
With Rects
.Left = 100
.Top = 100
.Right = ListView1.Width / Screen.TwipsPerPixelX
.Bottom = ListView1.Height / Screen.TwipsPerPixelX
End With
'下面这句用来控制区域
SendMessage ListView1.hwnd, LVM_SETWORKAREA, 1, Rects
'下面这句用来控制ListItem之间的距离,横向间距80像素,纵向间距50像素
Call SendMessage(ListView1.hwnd, LVM_SETICONSPACING, 0, ByVal (50 * 65536 + 80&))
End Sub
追问
有用!!
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询