VB Notebook Main Page VB Notebook Files VB Notebook Function Library VB Notebook Articles VB Notebook Links VB Notebook

VBNotebook Home | Functions | Enlarge Dropdown Area - This routine allows you to make the dropdown area of a combo box larger.

First, in General|Declarations, include the following...
__________________________________________________________________________________________

'
' Types for API Calls
'

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
'
' API Calls
'

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

__________________________________________________________________________________________

And the routine itself....
__________________________________________________________________________________________

Public Sub SetComboListAreaSize(frmHost As Form, cboCombo As ComboBox)

    Dim pt As POINTAPI
    Dim rec As RECT
    Dim iItemWidth As Integer
    Dim iItemHeight As Integer
    Dim iOldScaleMode As Integer
    Dim nRet As Long

    iOldScaleMode = frmHost.ScaleMode
    frmHost.ScaleMode = vbPixels
    iItemWidth = cboCombo.Width
    iItemHeight = frmHost.ScaleHeight - cboCombo.Top - 5
    frmHost.ScaleMode = iOldScaleMode
    nRet = GetWindowRect(cboCombo.hwnd, rec)
    pt.x = rec.Left
    pt.y = rec.Top
    nRet = ScreenToClient(frmHost.hwnd, pt)
    nRet = MoveWindow(cboCombo.hwnd, pt.x, pt.y, iItemWidth, iItemHeight, 1)

End Sub

__________________________________________________________________________________________

Copyright 2000-2005, J. Frank Carr