发送LB_SETHORIZONTALEXTENT消息LB_SETHORIZONTALEXTENT
An application sends an LB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden. LB_SETHORIZONTALEXTENT
wParam = (WPARAM) cxExtent; // horizontal scroll width
lParam = 0; // not used; must be zero
Parameters
cxExtent
Value of wParam. Specifies the number of pixels by which the list box can be scrolled.
Windows 95 and Windows 98: The wParam parameter is limited to 16-bit values. Return Values
This message does not return a value. Res
To respond to the LB_SETHORIZONTALEXTENT message, the list box must have been defined with the WS_HSCROLL style. QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
An application sends an LB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden. LB_SETHORIZONTALEXTENT
wParam = (WPARAM) cxExtent; // horizontal scroll width
lParam = 0; // not used; must be zero
Parameters
cxExtent
Value of wParam. Specifies the number of pixels by which the list box can be scrolled.
Windows 95 and Windows 98: The wParam parameter is limited to 16-bit values. Return Values
This message does not return a value. Res
To respond to the LB_SETHORIZONTALEXTENT message, the list box must have been defined with the WS_HSCROLL style. QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
解决方案 »
- VB计算字数的问题
- Combo1
- 图片放大缩小的功能(VB)
- xinliangyu(yxl) 接分5(VB IDE)
- activereport中控件边线做表格线的问题!
- 高分求:UDP 传送文件 或 二进制数据的例子. (主要问题就是解决丢包的难题: 我快崩溃了)
- 救命啊,难!在VB中一个整数(占4字节)的4个字节中是如何分布表示的?求救!!!
- 翻来覆去没问题?!
- 怎样实现子窗口和主窗口信息(指针)同步
- 有个小问题:如何可以在treeview和listvuew之间加个分隔条,可以自由拉动?
- 等待!!!请问:怎样在关闭a窗口时把最小化状态的b窗口最大化?
- 程序中用到word9.0的库,但如果用户没有安装office怎么办?
===============================================在ListBox适当设定水平滚动条的宽度
作者:李志东
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 LongPrivate Sub Command1_Click()
Dim max As Long, f As Font, i As IntegerMe.ScaleMode = vbPixels
Set f = Me.Font
Set Me.Font = List1.FontWith 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 + 10Set Me.Font = fSendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, max, ByVal 0&
End SubPrivate Sub Form_Load()
List1.AddItem "VB编程乐园"
List1.AddItem "http://vbboshi.126.com"
List1.AddItem "这是一个特别特别长的选项,长到超过ListBox的范围"
End Sub
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 LB_SETHORIZONTALEXTENT = &H194
Private Sub Command1_Click()
List1.AddItem "Line 1"
List1.AddItem "a big Line 2 some text some text"
List1.AddItem "Line 3"
addHorScrlBarListBox List1
End Sub
Public Sub addHorScrlBarListBox(ByVal refControlListBox As Object)
' 加横向滚动条
Dim nRet As Long
Dim nNewWidth As Integer
nNewWidth = refControlListBox.Width + 100 ' 新宽度,以像素为单位。
nRet = SendMessage(refControlListBox.hwnd, _
LB_SETHORIZONTALEXTENT, nNewWidth, ByVal 0&)
End Sub