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_SETITEMHEIGHT = &H1A0 Private Const CB_SETITEMHEIGHT = &H153' Set the height in pixels of each entry in a ListBox or ComboBox control Sub SetListItemHeight(ctrl As Control, ByVal newHeight As Long) Dim uMsg As Long If TypeOf ctrl Is ListBox Then uMsg = LB_SETITEMHEIGHT ElseIf TypeOf ctrl Is ComboBox Then uMsg = CB_SETITEMHEIGHT Else Exit Sub End If ' (only the low-order word of lParam can be used.) SendMessage ctrl.hwnd, uMsg, 0, ByVal CLng(newHeight And &HFFFF&) ' It is necessary to manually refresh the control. ctrl.Refresh End Sub
你要调用这个函数啊 晕死 SetListItemHeight 你要改变的句柄,你要的高度
SetListItemHeight List1, 1000 这样是吗,我做了,但是不起作用呀
刚试过的代码,有效:(在form 上放一个 list1,一个 command1)Option ExplicitPrivate 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_SETITEMHEIGHT = &H1A0 Private Const CB_SETITEMHEIGHT = &H153' Set the height in pixels of each entry in a ListBox or ComboBox control Sub SetListItemHeight(ctrl As Control, ByVal newHeight As Long) Dim uMsg As Long If TypeOf ctrl Is ListBox Then uMsg = LB_SETITEMHEIGHT ElseIf TypeOf ctrl Is ComboBox Then uMsg = CB_SETITEMHEIGHT Else Exit Sub End If ' (only the low-order word of lParam can be used.) SendMessage ctrl.hwnd, uMsg, 0, ByVal CLng(newHeight And &HFFFF&) ' It is necessary to manually refresh the control. ctrl.Refresh End SubPrivate Sub Command1_Click() SetListItemHeight List1, 20 End SubPrivate Sub Form_Load() Dim i As Integer For i = 1 To 9 List1.AddItem CStr(i) Next End Sub
Private Const LB_SETITEMHEIGHT = &H1A0
Private Const CB_SETITEMHEIGHT = &H153' Set the height in pixels of each entry in a ListBox or ComboBox control
Sub SetListItemHeight(ctrl As Control, ByVal newHeight As Long)
Dim uMsg As Long
If TypeOf ctrl Is ListBox Then
uMsg = LB_SETITEMHEIGHT
ElseIf TypeOf ctrl Is ComboBox Then
uMsg = CB_SETITEMHEIGHT
Else
Exit Sub
End If
' (only the low-order word of lParam can be used.)
SendMessage ctrl.hwnd, uMsg, 0, ByVal CLng(newHeight And &HFFFF&)
' It is necessary to manually refresh the control.
ctrl.Refresh
End Sub
晕死
SetListItemHeight 你要改变的句柄,你要的高度
这样是吗,我做了,但是不起作用呀
Private Const LB_SETITEMHEIGHT = &H1A0
Private Const CB_SETITEMHEIGHT = &H153' Set the height in pixels of each entry in a ListBox or ComboBox control
Sub SetListItemHeight(ctrl As Control, ByVal newHeight As Long)
Dim uMsg As Long
If TypeOf ctrl Is ListBox Then
uMsg = LB_SETITEMHEIGHT
ElseIf TypeOf ctrl Is ComboBox Then
uMsg = CB_SETITEMHEIGHT
Else
Exit Sub
End If
' (only the low-order word of lParam can be used.)
SendMessage ctrl.hwnd, uMsg, 0, ByVal CLng(newHeight And &HFFFF&)
' It is necessary to manually refresh the control.
ctrl.Refresh
End SubPrivate Sub Command1_Click()
SetListItemHeight List1, 20
End SubPrivate Sub Form_Load()
Dim i As Integer
For i = 1 To 9
List1.AddItem CStr(i)
Next
End Sub