CTabCtrl focus MS VC++ 6.0 - Programmer

This is a discussion on CTabCtrl focus MS VC++ 6.0 - Programmer ; Hello, I have written a class derived from Dialog (CDlgDataProc) which contains a CTabCtrl derived object (CTabDataProcess) and two CButtons (OK and Cancel). The CTabDataProcess contains 3 tabs, each tab contains a CDialog derived class. Everything works fine but I ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: CTabCtrl focus MS VC++ 6.0

  1. CTabCtrl focus MS VC++ 6.0

    Hello,

    I have written a class derived from Dialog (CDlgDataProc) which
    contains a CTabCtrl derived object (CTabDataProcess) and two CButtons
    (OK and Cancel). The CTabDataProcess contains 3 tabs, each tab contains
    a CDialog derived class.

    Everything works fine but I have a navigation problem using the TAB
    key. The focus starts in the OK Button, then jumps to the Cancel
    Button, then jumps into the dialog inside the tab control. So, the
    CTabDataProcess never gets the focus, and I need that to move between
    the tabs using the keyboard. If I press the TAB key in the last object
    within a tab the focus move to the OK Button of the main dialog.

    I've set the CTabDataProcess class and the CDialog derived classes
    (used in the tabs) with the WS_EX_CONTROLPARENT. I read something about
    the IsDialogMessage and PreTranslateMessage but I do not understand
    what I have to do with that.

    Here is the piece of code where I set the WS_EX_CONTROLPARENT style to
    the CTabCtrl and CDialogs used within the tabs.

    int CTabDataProcess::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if( CTabCtrl::OnCreate(lpCreateStruct) == -1 )
    return -1;

    DWORD dwStyle;
    dwStyle=GetStyle();
    ModifyStyle(0, dwStyle | WS_TABSTOP | WS_CHILD | DS_CONTROL );
    dwStyle=GetExtendedStyle();
    ModifyStyleEx( 0, dwStyle | WS_EX_CONTROLPARENT );

    CRect Rectangulo;
    nCantidadTabs = CANTIDAD_TABS;
    for( int nIndice=0 ; nIndice {
    Ventanas[nIndice] = NULL;

    switch( nIndice )
    {
    case GENERALES:
    InsertItem( nIndice, "Generales" );
    Ventanas[nIndice] = new CDlgProcDatosGenerales(this);
    Ventanas[nIndice]->Create(IDD_PROC_DATOS_GENERALES, NULL);
    break;
    case PLANIFICACION:
    InsertItem( nIndice, "Planificación" );
    Ventanas[nIndice] = new CDlgProcDatosPlanificacion(this);
    Ventanas[nIndice]->Create(IDD_PROC_DATOS_PLANIFICACION, NULL );
    break;
    case EJECUCION:
    InsertItem( nIndice, "Ejecución" );
    Ventanas[nIndice] = new CDlgProcDatosEjecucion(this);
    Ventanas[nIndice]->Create(IDD_PROC_DATOS_EJECUCION, NULL );
    break;
    }

    if( Ventanas[nIndice] != NULL )
    {
    Ventanas[nIndice]->SetParent(this);
    Ventanas[nIndice]->GetWindowRect( &Rectangulo );
    Ventanas[nIndice]->SetWindowPos( &wndTop, 5, 30, Rectangulo.Width(),
    Rectangulo.Height(), SWP_SHOWWINDOW );
    Ventanas[nIndice]->ShowWindow(SW_HIDE);
    dwStyle=Ventanas[nIndice]->GetStyle();
    Ventanas[nIndice]->ModifyStyle(0, dwStyle | WS_TABSTOP | WS_CHILD );
    dwStyle=Ventanas[nIndice]->GetExStyle();
    Ventanas[nIndice]->ModifyStyleEx( 0, dwStyle | WS_EX_CONTROLPARENT
    );
    }
    }
    Ventanas[0]->ShowWindow(SW_SHOW);
    nVentanaActiva = 0;

    return 0;
    }


  2. Re: CTabCtrl focus MS VC++ 6.0

    Hallo mbunirigo@hotmail.com!

    > I have written a class derived from Dialog (CDlgDataProc) which
    > contains a CTabCtrl derived object (CTabDataProcess) and two CButtons
    > (OK and Cancel). The CTabDataProcess contains 3 tabs, each tab contains
    > a CDialog derived class.


    Why aren't you using a CPropertySheet with CPropertyPages?

    --
    Martin Richter [MVP] WWJD
    "In C we had to code our own bugs. In C++ we can inherit them."
    FAQ : http://www.mpdvc.de
    Samples: http://www.codeguru.com http://www.codeproject.com

+ Reply to Thread