Article ID: 201116
Article Last Modified on 10/2/2003
65881 INFO: The Parts of a Windows Combo Box and How They Relate
class CCtrlsView : public CFormView
{
public:
CComboBox m_comboindex;
int m_currentIndex;
#ifdef _MAC
CListBox m_comboList;
#endif
...
};
void CCtrlsView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
#ifdef _MAC
// Obtain pointer to combo's list box.
HWND hComboList = m_comboindex.GetWindow(GW_CHILD)->m_hWnd;
ASSERT(hComboList);
// Verify class name.
char className[50];
GetClassName(hComboList, className, 50);
ASSERT(lstrcmp(className, "ComboLBox") == 0);
// Subclass to use CListBox.
m_comboList.SubclassWindow(hComboList);
#endif
...
}
// A simple combo box with "set" and "get" buttons using
// the values from an edit control.
void CCtrlsView::OnSetindex()
{
UpdateData(TRUE);
#ifndef _MAC
m_comboindex.SetTopIndex(m_currentIndex);
#else
m_comboList.SetTopIndex(m_currentIndex);
#endif
}
void CCtrlsView::OnGetindex()
{
#ifndef _MAC
m_currentIndex = m_comboindex.GetTopIndex();
#else
m_currentIndex = m_comboList.GetTopIndex();
#endif
UpdateData(FALSE);
}
Additional query words: Macintosh CB_GETTOPINDEX CB_SETTOPINDEX combobox listbox
Keywords: kbbug KB201116