Private Declare Function SendMessage Lib _
"USER32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal Msg As Long, _ ByVal wParam As Long, ByVal lParam As _ Long) As Long Private Const CB_GETDROPPEDWIDTH = &H15F Private Const CB_SETDROPPEDWIDTH = &H160 Private Const CB_ERR = -1 Public Function GetDropdownWidth(cboHwnd As Long) As Long Dim lRetVal As Long '*** To get the combo box drop-down width. '*** You may use this function if you want '*** to change the width in proportion '*** i.e. double, half, 3/4 of existing width. lRetVal = SendMessage(cboHwnd, CB_GETDROPPEDWIDTH, 0, 0) If lRetVal <> CB_ERR Then GetDropdownWidth = lRetVal 'Width in pixels Else GetDropdownWidth = 0 End If End Function Public Function SetDropdownWidth(cboHwnd As _ Long, NewWidthPixel As Long) As Boolean Dim lRetVal As Long ' *** To set combo box drop-down width *** lRetVal = SendMessage(cboHwnd, _ CB_SETDROPPEDWIDTH, NewWidthPixel, 0) If lRetVal <> CB_ERR Then SetDropdownWidth = True Else SetDropdownWidth = False End If End Function |