ComboBox with Item Tooltips

Include TooltipComboBox.h, TooltipComboBox.cpp,
TooltipListCtrl.h and TooltipListCtrl.cpp in your
project.

In the resource editor create a droplist combobox.

Create a control member variable for the combobox in VC's
classwizard.

Include TooltipComboBox.h and replace CComboBox with
CTooltipComboBox in your .h file. Also include afxtempl.h to support CMap.

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.

selected item visible

Fix for missing CBN_SELCHANGE message (fixes ON_CBN_SELCHANGE issues)

Posted by Mr. X
on 09/03/2004 07:00am

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
Enter-key.***]:
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 );
}

not fully working

Posted by psychodad
on 08/29/2004 11:46am

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.

ComboBox strupid selection

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 !
fov