comboListBox 的下拉长度如何指定?
如我想点击下一次拉出50条记录,默认的太少了。
如我想点击下一次拉出50条记录,默认的太少了。
解决方案 »
- 在一个text中输入学号,另一个text显示出相对应的姓名,如何解决?
- ListView控件在List视图模式下的项显示宽度问题
- 提示“系统使用级别选择”
- 请问如何用VB实现IP网关DNS更改,特别是DNS好难改
- 如何在类模块中加载控件?
- 初学者关于“安装程序”的两个问题,请帮忙解答,谢谢!
- 控制声音
- ACCESS数据库会自动丢失数据?
- 在标准对话框中添加一个按钮后,如何使对话框处理按钮的消息?(恭请zyl910及其他高人出手!))
- 我认为不太难,可就是做不出来。
- 怎么用ADO来查询给定的时间呢?
- 求助~~~!如何把一张640X480 Pix的图片划分为5个部分?并计算每部分为128X96 Pix的RGB和亮度值?
MaxDropDownItems属性
(ByVal hwnd As Long, ByVal x As Long, ByVal y As _
Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal bRepaint As Long) As LongPublic Sub SetComboHeight(oComboBox As ComboBox, lNewHeight As Long)
Dim oldscalemode As Integer
If TypeOf oComboBox.Parent Is Frame Then Exit Sub
oldscalemode = oComboBox.Parent.ScaleMode
oComboBox.Parent.ScaleMode = vbPixels
MoveWindow oComboBox.hwnd, oComboBox.Left, _
oComboBox.Top, oComboBox.Width, lNewHeight, 1
oComboBox.Parent.ScaleMode = oldscalemode
End SubPrivate Sub Form_Load()
Dim i As Integer
For i = 1 To 50
Combo1.AddItem i
Next i
Call SetComboHeight(Combo1, 667)
End Sub
Private Const CB_SETITEMHEIGHT = &H153
Private Sub Form_Load()
dim lngHeight as Long '你要设置的高度,Pixel(像素)单位
lngHeight=5000
Call SendMessageA(Combo1.hwnd, CB_SETITEMHEIGHT, 0, lngHeight)
End Sub
Private Const CB_SETITEMHEIGHT = &H153
Private Sub Form_Load()
dim lngHeight as Long '你要设置的高度,Pixel(像素)单位
lngHeight=5000
Call SendMessageA(Combo1.hwnd, CB_SETITEMHEIGHT, 0, lngHeight)
End Sub
试验无效果
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As LongPublic Declare Function GetWindowRect Lib "user32" _
(ByVal hWnd As Long, _
lpRect As RECT) As LongPublic Declare Function ScreenToClient Lib "user32" _
(ByVal hWnd As Long, _
lpPoint As POINTAPI) As LongPublic Declare Function MoveWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As LongPublic Const WM_SETREDRAW = &HB' Combo Box messages
Private Const CB_GETEDITSEL = &H140
Private Const CB_LIMITTEXT = &H141
Private Const CB_SETEDITSEL = &H142
Private Const CB_ADDSTRING = &H143
Private Const CB_DELETESTRING = &H144
Private Const CB_DIR = &H145
Private Const CB_GETCOUNT = &H146
Private Const CB_GETCURSEL = &H147
Private Const CB_GETLBTEXT = &H148
Private Const CB_GETLBTEXTLEN = &H149
Private Const CB_INSERTSTRING = &H14A
Private Const CB_RESETCONTENT = &H14B
Private Const CB_FINDSTRING = &H14C
Private Const CB_SELECTSTRING = &H14D
Private Const CB_SETCURSEL = &H14E
Private Const CB_SHOWDROPDOWN = &H14F
Private Const CB_GETITEMDATA = &H150
Private Const CB_SETITEMDATA = &H151
Private Const CB_GETDROPPEDCONTROLRECT = &H152
Private Const CB_SETITEMHEIGHT = &H153
Private Const CB_GETITEMHEIGHT = &H154
Private Const CB_SETEXTENDEDUI = &H155
Private Const CB_GETEXTENDEDUI = &H156
Private Const CB_GETDROPPEDSTATE = &H157
Private Const CB_FINDSTRINGEXACT = &H158
Private Const CB_SETLOCALE = &H159
Private Const CB_GETLOCALE = &H15A
Private Const CB_MSGMAX = &H15BPrivate Type POINTAPI
x As Long
y As Long
End TypePrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePublic Sub ComboLines(ComboForm As Form, _
ComboControl As Control, iLines As Integer)' Sets the number of lines displayed in the combo box
' drop-down list.' Pass -1 for iLines to set equal to number of items
' in the combobox.Dim pt As POINTAPI
Dim rc As RECT
Dim newHeight As Long
Dim oldScaleMode As Long
Dim oldTop As Long
Dim oldLeft As Long
Dim oldWidth As Long
Dim itemHeight As LongIf iLines = -1 Then
iLines = ComboControl.ListCount
End IfoldTop = ComboControl.Top
oldLeft = ComboControl.Left
oldWidth = ComboControl.Width
oldScaleMode = ComboForm.ScaleMode
ComboForm.ScaleMode = vbPixels
itemHeight = SendMessage(ComboControl.hWnd, _
CB_GETITEMHEIGHT, 0, 0)
newHeight = itemHeight * (iLines + 2)'Get the co-ordinates of the combo box
'relative to the screen
Call GetWindowRect(ComboControl.hWnd, rc)
pt.x = rc.Left
pt.y = rc.Top'Then translate into co-ordinates
'relative to the form.
Call ScreenToClient(ComboForm.hWnd, pt)'Using the values returned and set above,
'call MoveWindow to reposition the combo box
Call MoveWindow(ComboControl.hWnd, pt.x, pt.y, _
ComboControl.Width, newHeight, True)'restore the original form scalemode
'before leaving
ComboForm.ScaleMode = oldScaleMode
ComboControl.Top = oldTop
ComboControl.Left = oldLeft
ComboControl.Width = oldWidthEnd Sub