Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 261
Viewed: 2170
Added: Jul 26, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Change Number of Items Displayed in Combo Box

Highlight all by clicking in box
<!---Declaration--->
Private Type POINTAPI
x As Long
Y As Long
End Type

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

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


Highlight All
<!---Code--->
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)

End Sub
;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


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.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions