Tab order of controls *within* a COleControl 
Author Message
 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


Fri, 22 Nov 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Tab control and tab order

2. Control Tab Order Broken

3. Dialog Box Controls Tab Order Run-Time setting

4. TAB ORDER out of control (build problem)

5. TAB ORDER out of control

6. Tab order of controls on a dialog

7. Tab order of Controls

8. Tab order in dialog box with any activeX control

9. Set tab order to controls

10. Inserting controls into the tab order

11. About Tab order for controls

12. Tab order of runtime created controls

 

 
Powered by phpBB® Forum Software