Here's an alternative to using tooltips. Instead, you modify the width of only the dropdown portion of the combo...
VB Code:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Public Const CB_SETDROPPEDWIDTH = &H160 Public Const CB_ERR = (-1) Public Sub SetDropDownWidth(mCombo as ComboBox) Dim RetVal As Long Dim PixelWidth As Long Dim MaxWidth As Long Dim LoopCounter As Long Dim lWidth As Long For LoopCounter = 0 To mCombo.ListCount - 1 lWidth = mCombo.Parent.TextWidth(mCombo.list(LoopCounter)) If lWidth > MaxWidth Then MaxWidth = lWidth End If Next LoopCounter MaxWidth = MaxWidth + (23 * Screen.TwipsPerPixelX) If MaxWidth > (mCombo.Width * 2) Then MaxWidth = (mCombo.Width * 2) Elseif MaxWidth < mCombo.Width Then MaxWidth = mCombo.Width End If PixelWidth = (MaxWidth \ Screen.TwipsPerPixelX) RetVal = SendMessage(mCombo.hwnd, CB_SETDROPPEDWIDTH, PixelWidth, 0) End Sub
- gaffa




Reply With Quote