在ListBox适当设定水平滚动条的宽度

文章作者 100test 发表时间 2007:03:10 18:18:14
来源 100Test.Com百考试题网


Option Explicit
Private Const LB_SETHORIZONTALEXTENT = &.H194
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 Command1_Click()
Dim max As Long, f As Font, i As Integer

Me.ScaleMode = vbPixels
Set f = Me.Font
Set Me.Font = List1.Font

With List1
For i = 0 To .ListCount
If Me.TextWidth(.List(i)) > max Then
max = Me.TextWidth(.List(i))
End If
Next
End With
max = max 10

Set Me.Font = f

SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, max, ByVal 0&.
End Sub

Private Sub Form_Load()
List1.AddItem "VB编程乐园"
List1.AddItem "http://www.vbeden.com"
List1.AddItem "这是一个特别特别长的选项,长到超过ListBox的范围"
End Sub

相关文章


计算机等级考试二级VB考点分析之程序开发环境(2)
计算机等级考试二级VB考点分析之程序开发环境(1)
全国计算机二级(vf)sql语句练习2
全国计算机二级(vf)sql语句练习3
在ListBox适当设定水平滚动条的宽度
运行时改变控件大小的两种方法
二级VisualFoxpro新大纲(六)
VB中处理长列表框项的两种方法
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛