Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Dockbars don't fill entire area Collapse All
Subject Author Date
Andrew Harding Apr 14, 2006 - 10:40 AM

How do I make my CExtControlBar’s fill the entire client area automatically? Currently if I dock a couple of bars to the edges of the client area I then have to manually drag the windows so that they fill the empty space, every time I resize the client window I have to manually fill in the gap that’s created between the docking windows. This is causing customers no end of grief and annoyance.

Technical Support Apr 16, 2006 - 11:06 AM

The control bar was designed as a window which can be docked with any of the frame window borders or be floating over the frame window. There is only one chance to fill all the frame window with the bars: just use dynamic resizable control bars that support switching to the document view mode. These control bars are demonstrated in SDI_DynamicBars and MDI_DynamicBars samples.

Andrew Harding Apr 17, 2006 - 3:00 PM

I looked through the MDI_DynamicBars example and it looks like this should work for me, I’ll just make one of my windows an __EDBS_DOCUMENT and then make the others docked bars. I wrote a quick test program to be sure that it would work but apparently I’m missing something because my __EDBS_DOCUMENT window does not display, the other docking windows display just fine. Here’s my OnCreate function where I create the docking bars.

int MyFrameWnd::OnCreate( LPCREATESTRUCT lpcs )
{
    std::vector<CExtDynamicControlBar*>::iterator    itr, prevItr;
    CExtDynamicControlBar    *pBar;
    CEdit                    *pEdit;
    RECT                    rect;
    CString                    strBarCaption;
    UINT                    nDocBarID;

    if (CFrameWnd::OnCreate(lpcs) == -1)
        return -1;

    CWinApp * pApp = ::AfxGetApp();
    ASSERT( pApp != NULL );
    ASSERT( pApp->m_pszRegistryKey != NULL );
    ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );
    ASSERT( pApp->m_pszProfileName != NULL );
    ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );

    VERIFY(g_CmdManager->ProfileSetup(pApp->m_pszProfileName,GetSafeHwnd()));
    VERIFY(g_CmdManager->UpdateFromMenu(pApp->m_pszProfileName,IDR_MAINFRAME));

    if( !CExtControlBar::FrameEnableDocking(this) )
    {
        ASSERT( FALSE );
        return -1;
    }

    CExtDynamicBarSite::Install( this );

    m_icon.CreateEmptyIcon ( );
    for ( int i = 0; i < 4; i++ )
    {
        strBarCaption.Format ( _T("bar %d"), i );
        pBar = CExtDynamicBarSite::BarAlloc ( strBarCaption.GetString(), m_icon, IDC_BAR + i, RUNTIME_CLASS(CExtDynamicControlBar) );
        ASSERT ( pBar != NULL );
        m_vBars.push_back ( pBar );
    
        pBar->GetClientRect ( &rect );
        pEdit = new CEdit ( );
        pEdit->Create ( WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL, rect, pBar, IDC_EDIT + i );
        pEdit->SetWindowText ( strBarCaption.GetString() );
    }

    itr = m_vBars.begin();
    (*itr)->EnableDocking(CBRS_ALIGN_ANY);
    (*itr)->DockControlBarInnerOuter ( AFX_IDW_DOCKBAR_LEFT, true, this, true );
    for ( prevItr = itr; itr != m_vBars.end(); itr++ )
    {
        (*itr)->EnableDocking(CBRS_ALIGN_ANY);
        (*itr)->DockControlBar ( AFX_IDW_DOCKBAR_RIGHT, 0, this, true );
        prevItr = itr;
    }

    itr = m_vBars.begin();
    (*itr)->BarStateSet (CExtDynamicControlBar::__EDBS_DOCUMENT, true);
    for ( itr++; itr != m_vBars.end(); itr++ )
    {
        ShowControlBar( *itr, TRUE, TRUE );
    }

    RecalcLayout();

    return 0;
}

Andrew Harding Apr 17, 2006 - 4:34 PM

Oops, I just realized that the initializer for the docking loop is wrong, I still have the problem however even with the corrected loop. I have noticed that if I move the BarStateSet call above the docking loop that the _EDBS_DOCUMENT window actually appears but it’s not a document window.

for ( prevItr = itr; itr != m_vBars.end(); itr++ )

//should be

prevItr = itr;
for ( itr++; itr != m_vBars.end(); itr++ )

Technical Support Apr 18, 2006 - 7:58 AM

Please do not use the CFrameWnd::ShowControlBar() method with dynamic control bars. Just invoke pBar->BarStateSet( pBar->BarStateGet(), bShow ) instead

Andrew Harding Apr 18, 2006 - 3:36 PM

Ok I’ve got it all working now but I think I’ve found a bug. I’m using Prof-UIS 2.52 (non-trial) version. If I use the BarStateSet method to hide a control bar that has the state CExtDynamicControlBar::__EDBS_DOCUMENT and that control bar is not the selected tab then the program crashes. I tried this with the MDI_DynamicBars sample to verify that it is indeed a problem and not a bad implementation on my part, it happened there as well.

Andrew Harding Apr 18, 2006 - 3:50 PM

Ah nevermind, found the problem.

Andrew Harding Apr 18, 2006 - 4:44 PM

The bug is a problem but it’s restricted to SDI tab controls. In CExtDynamicControlBar::OnMoveChildToBar() on line 22444 you’re retrieving the selected page index of the page container and then removing that page rather than using the child’s HWND to find the correct page.