Guides & Tutorials (beta)

Upgrading Toolkit Standard to Toolkit Pro - Tabbed Dock Window Creation

by Kirk Stowell Visual C++ Created on 11/16/2007  |  Updated on 07/31/2024 0/5 ( 0 votes )

You use the same approach to create a tabbed dock window that you would to create a single dock window. For each tab you want to display, you would need to create a new pane. Once you have all of the panes created, you then group them by calling AttachPane and passing in the pane you want to attach as the first argument, and the pane that is acting as the tab control bar for the second argument. You will also need to call SetIcons to define the icons for each tab.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create Status bar. 
    // Important: All control bars including the Status Bar 
    // must be created before CommandBars....
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }

    // Initialize the Command Bar
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the Command Bar object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create Command Bar object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
        _T("Menu Bar"), IDR_MDISAMTYPE);
    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

    // Create ToolBar
    CXTPToolBar* pToolBar = (CXTPToolBar*)
        pCommandBars->Add(_T("Standard"), xtpBarTop);
    if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;
    }

    // Initialize the docking pane manager and set the
    // initial them for the docking panes.  Do this only 
    // after all control bars objects have been created 
    // and docked.
    GetDockingPaneManager()->InstallDockingPanes(this);
    GetDockingPaneManager()->SetTheme(xtpPaneThemeOffice);

    // Create the workspace bar.
    CXTPDockingPane* pwndDockWindow= GetDockingPaneManager()->
      CreatePane(IDC_DOCKWINDOW, CRect(0, 0,200, 120), dockLeftOf);

    CXTPDockingPane* pwndPane2  = GetDockingPaneManager()->
        CreatePane(IDC_PANE2, CRect(0, 0,200, 120), dockLeftOf);

    CXTPDockingPane* pwndPane3  = GetDockingPaneManager()->
        CreatePane(IDC_PANE3, CRect(0, 0,200, 120), dockLeftOf);

    // Initialize the default layout for "EditorLayout".
    GetDockingPaneManager()->AttachPane(
        pwndPane2, pwndDockWindow);
    GetDockingPaneManager()->AttachPane(
        pwndPane3, pwndDockWindow);

    // select the first tab.
    GetDockingPaneManager()->ShowPane(IDC_DOCKWINDOW);

    // Set the icons for the docking pane tabs.
    int nIDs[] = {IDC_DOCKWINDOW, 0, 0};
    GetDockingPaneManager()->SetIcons(IDB_IMGLIST_TAB, nIDs,
        _countof(nIDs), RGB(0,255,0));</font>

        // create the tree control for the dock pane.
        if (!m_wndTreeCtrl.Create( WS_VISIBLE | TVS_HASLINES |
            TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS,
            CRect(0,0,0,0), this, IDC_TREE_CTRL ))
        {
            TRACE0("Failed to create tree control.\n");
            return -1;      // fail to create
        }
        return 0;
}

Set the child window for the dock panes

Set the child window for each pane as described in the previous page. You can also attach views by calling AttachView as shown here:

LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
{
    if (wParam == XTP_DPN_SHOWWINDOW)
    {
        // get a pointer to the docking pane being shown.
        CXTPDockingPane* pwndDockWindow= (CXTPDockingPane*)lParam;
        if (!pwndTabDockBar->IsValid())
        {
            switch (pwndDockWindow ->GetID())
            {
            case IDC_DOCKWINDOW:
                {
                    pwndDockWindow->Attach(&m_wndTreeCtrl);
                    break;
                }
            case IDC_PANE2:
                {
                    CPane2View* pView =
                    (CPane2View*)pwndDockWindow->AttachView(this,
                    RUNTIME_CLASS(CPane2View));

                    pView->SendMessage(WM_INITIALUPDATE);
                    break;
                }
            case IDC_PANE3:
                {
                    CPane3View* pView =
                    (CPane3View*)pwndDockWindow->AttachView(this,

                    RUNTIME_CLASS(CPane3View));
                    pView->SendMessage(WM_INITIALUPDATE);
                    break;
                }
            }
        }

        return TRUE; // handled
    }

    return FALSE;
}

User Comments

No comments yet, sign in to comment.

Secure Transactions

Online transactions are secure and protected.


Ssl seal 1
This site is protected by Trustwave's Trusted Commerce program
CompliAssure Secured

Money Back Guarantee

If you are not 100% happy with your purchase within 30 days, you can return it for any reason. Your satisfaction is our priority!


Satisfication Guarantee

Contact sales@codejock.com for more details.