
Tab order of controls *within* a COleControl
I have an ActiveX control here, just a simple COleControl derived control
that adds a variable number of CEdit and CCombo controls at runtime (it's
actually a list of combo boxes with CEdit labels). The control is used in a
dialog (inserted with the resource editor).
The problem is that I want the combo boxes to get focus from the tab order
but it just ain't happening for me. The control's Tab Stop flag is set
after it's inserted into the dialog.
The combos are added when the controls row count (see code below) is
set/changed. I'm creating the combos with WS_TABSTOP and I'm using
SetWindowPos() to (hopefully) insert them into the tab order.
It doesn't work. As I tab through the controls in the dialog, the CBList
gets focus (I have trace from CCBListCtrl::OnSetFocus) but instead of
letting me tab through the combo boxes, it just passes them by and focus
moves to the next button in the dialog.
void CCBListCtrl::SetRowCount(short nNewValue)
{
CWnd *pWndInsertAfter;
int iResult;
pWndInsertAfter = this;
do
{
CComboBox* pcb = new CComboBox;
m_ComboList.AddTail(pcb);
if (m_hWnd != NULL)
{
pcb->Create(WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT,
rcCB,
this,
NULL);
iResult = pcb->SetWindowPos(pWndInsertAfter, rcCB.left, rcCB.top,
rcCB.Width(), rcCB.Height(), 0);
TRACE("SetWindowPos returned %d\n", iResult);
pWndInsertAfter = pcb;
....
rcCB.OffsetRect(0, m_nRowHeight);
rcEB.OffsetRect(0, m_nRowHeight);
}
} while (++m_nRowCount < nNewValue);
InvalidateControl();
AdjustScrollBars();
SetModifiedFlag();
Quote:
}
Simon