Results 1 to 4 of 4

Thread: Combo Box and Tooltips

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    San Jose
    Posts
    70

    Question Combo Box and Tooltips

    Hi All,

    I have created a combo box and added a list of sotfware titles.
    When I click on the drop down button the titles are populated in the combo boxes list view. Some of these titles are longer then the combo box.

    What I was wondering is if there is a way to check the titles in the drop down list of the combo box (as the mouse moves over). and if the text is too long (in the drop down portion of the combo box) have it displayed in the tooltip?

    Thanks.




  2. #2
    DaoK
    Guest
    ToolTipText is only when the object is in "wait mode" I do not think you can see the the ToolTipText can be seen when the combo box are open. If the combo is close you can use
    Combo1.ToolTipText = Combo1.Text

  3. #3
    DaoK
    Guest
    Here si an exemple :

    VB Code:
    1. Private Sub Combo1_Click()
    2. Combo1.ToolTipText = Combo1.Text
    3. End Sub
    4.  
    5. Private Sub Form_Load()
    6. Combo1.Clear
    7. Combo1.Width = 1000
    8. Combo1.AddItem "LongStringWhoILikeALot"
    9. Combo1.AddItem "LittleString"
    10. End Sub

    Here is the picture :

  4. #4
    gaffa
    Guest
    Here's an alternative to using tooltips. Instead, you modify the width of only the dropdown portion of the combo...

    VB Code:
    1. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
    2.                                           ByVal wMsg As Long, _
    3.                                           ByVal wParam As Long, _
    4.                                           lParam As Any) As Long
    5. Public Const CB_SETDROPPEDWIDTH = &H160
    6. Public Const CB_ERR = (-1)
    7.  
    8. Public Sub SetDropDownWidth(mCombo as ComboBox)
    9.     Dim RetVal As Long
    10.     Dim PixelWidth As Long
    11.     Dim MaxWidth As Long
    12.     Dim LoopCounter As Long
    13.     Dim lWidth As Long
    14.  
    15.     For LoopCounter = 0 To mCombo.ListCount - 1
    16.         lWidth = mCombo.Parent.TextWidth(mCombo.list(LoopCounter))
    17.         If lWidth > MaxWidth Then
    18.             MaxWidth = lWidth
    19.         End If
    20.     Next LoopCounter
    21.  
    22.     MaxWidth = MaxWidth + (23 * Screen.TwipsPerPixelX)
    23.     If MaxWidth > (mCombo.Width * 2) Then
    24.         MaxWidth = (mCombo.Width * 2)
    25.     Elseif MaxWidth < mCombo.Width Then
    26.         MaxWidth = mCombo.Width
    27.     End If
    28.  
    29.     PixelWidth = (MaxWidth \ Screen.TwipsPerPixelX)
    30.     RetVal = SendMessage(mCombo.hwnd, CB_SETDROPPEDWIDTH, PixelWidth, 0)
    31. End Sub

    - gaffa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width