You can set the drop down height and width by sending a message, and using the MoveWindow Windows API function. Use the following code to set its height and width:
' Declare functions
' Move Window is for SetDropHeight
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
' SendMessage is for Set Drop Width
Private Declare Function SendMessageLong Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
' Constant for SetDropWidth
Private Const CB_SETDROPPEDWIDTH = &H160
' SetDropWidth
Private Sub SetDropWidth(lngWidth As Long)
Dim lRet As Long
lRet = SendMessageLong(Combo1.hwnd, CB_SETDROPPEDWIDTH,
lngWidth, 0)
End Sub
' SetDropHeight
Private Sub SetDropHeight(lngHeight As Long)
Dim lRet As Long
Dim iScaleMode As Integer
iScaleMode = Combo1.Parent.ScaleMode
Combo1.Parent.ScaleMode = vbPixels
lRet = MoveWindow(Combo1.hwnd, Combo1.Left, Combo1.Top,
Combo1.Width, lngHeight, 1)
Combo1.Parent.ScaleMode = iScaleMode
End Sub
Comments