Added: Jul 26, 2002
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo
Change Number of Items Displayed in Combo Box
Highlight all by clicking in box
Private Type POINTAPI
x As Long
Y As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ScreenToClient Lib "user32" _
(ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private 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 Long
Public Sub SetComboListAreaSize(objForm As Form, cboCombo As ComboBox)
' Makes the dropdown area of a combo box larger
Dim pt As POINTAPI
Dim rec As RECT
Dim iItemWidth As Integer
Dim iItemHeight As Integer
Dim iOldScaleMode As Integer
Dim nRet As Variant
'Change the Scale Mode on the form to Pixels.
iOldScaleMode = objForm.ScaleMode
objForm.ScaleMode = vbPixels
'Set the Width and new Height of the combo box.
iItemWidth = cboCombo.Width
iItemHeight = objForm.ScaleHeight - cboCombo.Top - 5
objForm.ScaleMode = iOldScaleMode
'Get the coordinates relative to the screen,
nRet = GetWindowRect(cboCombo.hwnd, rec)
pt.x = rec.Left
pt.Y = rec.Top
'then the coordinates relative to the form.
nRet = ScreenToClient(objForm.hwnd, pt)
'Finally, resize the combo box.
nRet = MoveWindow(cboCombo.hwnd, pt.x, pt.Y, iItemWidth, iItemHeight, 1)
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.