ComboBox with Item Tooltips


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment: VC6 SP5, NT4 SP6 ( not tested on other OS )

To use this combo box, follow the following steps:

  1. Include TooltipComboBox.h, TooltipComboBox.cpp, TooltipListCtrl.h and TooltipListCtrl.cpp in your project.
  2. In the resource editor create a droplist combobox.
  3. Create a control member variable for the combobox in VC's classwizard.
  4. Include TooltipComboBox.h and replace CComboBox with CTooltipComboBox in your  .h file. Also include afxtempl.h to support CMap.
  5. To have your own tips, you can either use SetItemTip, SetComboTip functions, or replace GetItemTip function in CTooltipListCtrl, and GetComboTip function in CTooltipComboBox.

Cause this combo box uses CComboBox's listbox to store items, it has no special behavior, and can be used a usual CComboBox. It uses Hai Ha's article style to replace standard drop-down list with a virtual list control. A virtual one to prevent having two identical lists. Only droplist combo style is currently working like standard CComboBox.

I think the code is simple enough and doesn't need any other comments.


Download source - 6 Kb


  • It doesn't work

    Posted by symreds on 10/21/2011 11:12am

    The combo doesn't drop down...

  • Perfect - if only there was a way to make multiline tooltips

    Posted by Mike Pliam on 11/02/2006 09:43am

    This is just what I've been looking for. It would really be ideal if I could link the items to multi-line tooltips from a WinHelp file.

  • selected item visible

    Posted by shean85 on 09/13/2004 11:48pm

    How to make selected item from the combobox to be visible when I open the combobobox again (to scroll , to make selected item visible) thank you

  • Fix for missing CBN_SELCHANGE message (fixes ON_CBN_SELCHANGE issues)

    Posted by Mr. X on 09/03/2004 02:00pm

    This tooltip combobox control works well, once you have fixed:
    (1) the compiler error and 
    (2) handling sorted lists
    (3) added sending CBN_ONSELECT message
    The latter is a problem if you happen to have
    code that depends on the combobox selection made
    it will never be called -- for example if your
    dialog enables/disables other controls depending
    on the choice made. This problem occurs because, 
    unlike MFC's CComboBox, this one does not send a
    CBN_SELCHANGE message when a new selection is 
    made, consequently, any message handlers are
    never called.
    e.g. Method OnSelchangeCombo1() for entries like 
    this in your dialog's message map: 
    ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)).
    The following update (implemented in the child 
    TooltipList control) fixes the problem 
    [***Note: this fix works with selections made by 
    mouse-button, mouse-wheel, arrow-keys and/or the 
    void CTooltipListCtrl::OnKillFocus(CWnd* pNewWnd) 
    	CPoint point;
    	GetCursorPos( &point );
    	CWnd *pWnd = WindowFromPoint( point );
    	if ( pWnd->GetSafeHwnd( ) != m_pComboParent->GetSafeHwnd( ) )
    		ShowWindow( SW_HIDE );
    		// AJY Start fix.
    		CWnd *pParentDlg = m_pComboParent->GetParent(); // The parent's parent (typically the dialog window)
    		pParentDlg->PostMessage(WM_COMMAND,MAKELONG(m_pComboParent->GetDlgCtrlID(), CBN_SELCHANGE),(LPARAM)m_pComboParent->m_hWnd);
                    // AJY End Fix.
    	m_pComboParent->SetCurSel( m_nLastItem );
    	m_pComboParent->SetFocus( );
    	CListCtrl::OnKillFocus( pNewWnd );

    • This worked for me.

      Posted by paresh_chitte on 02/16/2007 03:41pm


    • This was also required by me

      Posted by NtwoO on 09/07/2004 04:38pm

      Tnx for the fix.

  • Fix for Paul Garber's sorted list fix

    Posted by Mr. X on 09/03/2004 01:46pm

    Thanks for the sorted list fix Paul.  
    There was a small but obvious bug in the fix 
    (most likely a typo).  Here is the fixed code:
    // Additional code from Paul Garber (codeguru.com) required to correctly order tooltips for sorted lists.
    int CTooltipListCtrl::InsertItemTip( int nRow, CString sTip)
      if (nRow < 0)
        return -1;
      if ( nRow < m_pComboParent->GetCount( ) )	
        for (int i = m_pComboParent->GetCount( ) - 1; i >= nRow; --i)
    		// AJY Serious but obvious BUG: m_itemToTip[nRow + 1] = GetItemTip(i);
    		// Shuffle existing tips at the end of the list along to squeeze new one into the correct place.
    		int idxNew = i + 1;	// Templates can't handle expressions in-line.
    		m_mpItemToTip[idxNew] = (CString)GetItemTip(i);
      m_mpItemToTip[nRow] = sTip;
      return nRow;

  • Fix for compiler error under VS.NET 7.1

    Posted by Mr. X on 09/03/2004 01:41pm

    Here is a fix for the compiler error that I saw when compiling this control under VS.NET 7.1:
    	// AJY - The following code would not compile in VS7:
    	// OLD:  m_lstCombo.CreateEx( 0, WC_LISTVIEW, NULL, dwStyle, rc, this, 0 );
    	CWnd* pWnd = &m_lstCombo;
    	pWnd->CreateEx( 0, WC_LISTVIEW, NULL, dwStyle, rc, this, 0 );
    	// AJY End.

  • not fully working

    Posted by psychodad on 08/29/2004 06:46pm

    if you place 2 or more tooltipcombos into a dialog and move the mouse over one combobox it shows the tooltip, but if you go over another one its not shown. its always only shown on the first combo you hit. can someone help me plz to fix this, i found no solution :/ the selchanged event isnt working too.

  • The tootip isn't shown...

    Posted by Legacy on 01/19/2004 08:00am

    Originally posted by: Tommy Svensson

    For those of you who don't see the tooltip...
    Make sure that you insert tooltip texts, starting with row 0! (Instead of row 1).

    m_comboCars.SetItemTip(0,"Volvo 1234567890");
    m_comboCars.SetItemTip(1,"Volvo 3141592654");
    m_comboCars.SetItemTip(2,"Volvo 2714241424");


  • How We Can Change A Font Of TextBox ?

    Posted by Legacy on 10/16/2003 07:00am

    Originally posted by: mohammed aseer


  • ComboBox strupid selection

    Posted by Legacy on 07/31/2003 07:00am

    Originally posted by: fov

    Hi folkes !
    I'm using visual c++ 6 and need to know the value of the new selected item in a combo box. When using CBN_SELCHANGE or CBN_SELENDOK with WM_GETTEXT the result is actually the old item value as the above two messages are processed before the new value is set. How can I get the new value ?
    Thank you !

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date