Thank you Jochen, I gave you 4 of 5 points for leading me into the correct direction. My final solution is this:
Override OnCtrlColor
HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_LISTBOX)
{
if (m_hwndListBox == NULL)
{
m_hwndListBox = pWnd->GetSafeHwnd();
CListBox *pLb = (CListBox*)CWnd::FromHandle(m_hwndListBox);
int nSelIndex = ::SendMessage(m_hwndListBox, LB_GETCURSEL, 0, 0);
if (nSelIndex >= 1)
{
if (nSelIndex == ::SendMessage(m_hwndListBox, LB_GETTOPINDEX, 0, 0))
::SendMessage(m_hwndListBox, LB_SETTOPINDEX, nSelIndex - 1, 0);
}
}
}
return __super::OnCtlColor(pDC, pWnd, nCtlColor);
}
m_hwndListBox
is a member of CMyComboBox and is initialized to NULL. The code inside the
if (m_hwndListBox == NULL)
scrolls the list box down one line if the current selection is the item displayed on the top row of the drop-down but not the first item in the list. This is the effect I wanted to create.
React to the CBN_CLOSEUP notification
In the message map of CMyComboBox, I added this entry:
ON_CONTROL_REFLECT(CBN_CLOSEUP, &OnReflectCbnCloseup)
The respective handler is short:
void CMyComboBox::OnReflectCbnCloseup()
{
m_hwndListBox = NULL;
}
It is executed when the drop-down closes.
Thanks again!