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 Tech Support » Dynamic bars question Collapse All
Subject Author Date
Rado Manzela May 21, 2010 - 6:58 AM

I have SDI frame which has no real child view, only dynamic bars. I’ve used some code from your SDI_DynamicBars sample including CChildView from this sample. I’ve created two dynamic bars (containing CExtResizableDialog dialogs). It works except I cannot rearrange bars or make them floating using drag&drop on bar tab, it ignores dragging (only when I switch bar using it’s menu to "dockable" i can only dock it) and it does not display icons used as drop targets to dock the bar. I cannot find any function in documentation how to turn d&d on.


Here is the code:



BOOL CSiteFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if(cs.hMenu!=NULL)
    {
        ::DestroyMenu(cs.hMenu);	  // delete menu if loaded
        cs.hMenu = NULL;			  // no menu for this window
    }

    if( ! CExtNCW < CFrameWnd > :: PreCreateWindow( cs ) )
        return FALSE;
    cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
    cs.lpszClass = AfxRegisterWndClass(0);
    return TRUE;
}

int CSiteFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CExtNCW<CFrameWnd>::OnCreate(lpCreateStruct) == -1)
        return -1;

    if( ! m_wndView.Create(
            this,
            CRect(0,0,0,0),
            AFX_IDW_PANE_FIRST
            )
        )
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }
    m_wndView.OrientationSet( __ETWS_ORIENT_TOP );
    m_wndView.ShowBtnCloseSet( true );
    m_wndView.ItemDraggingSet();
    m_wndView.CloseOnTabsSet();


    VERIFY(g_CmdManager->ProfileSetup(L"site",GetSafeHwnd())    );


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

    CExtDynamicBarSite::Install( this );
    
    CExtCmdIcon icon;
    m_pBarMain = CExtDynamicBarSite::BarAlloc(_T("Main"),icon,0,NULL,true);
    m_pBarForm = CExtDynamicBarSite::BarAlloc(_T("Form"),icon,0,NULL,true);
    ASSERT( m_pBarForm != NULL );

    m_wndMain.Create(CSiteMainDlg::IDD,m_pBarMain);
    m_wndForm.Create(CSiteFormDlg::IDD,m_pBarForm);

    m_pBarForm->BarStateSet(CExtDynamicControlBar::__EDBS_DOCUMENT,true);
    m_pBarMain->BarStateSet(CExtDynamicControlBar::__EDBS_DOCUMENT,true);

    return 0;
}

Is it possible to disable hiding the bar completely? (removing close button in tab, hide menu, etc.)


Thank you.

Rado Manzela May 24, 2010 - 3:45 AM

I’ve tried this but there are still dome bugs.



  1. docking markers are still not shown in any theme

  2. bars in tabbed document mode still shows big red X

  3. in new office themes when I drag bar from tabbed document state, I can make it only floating and then I can oly move it around screen, it does not let me put in any other state than floating using d&d. In the menu "Dockable" is selected, but I cannot dock it anywhere. But it works in old themes (I can dock it)

  4. In old themes when I make one bar floating and then paste other bar to first to make floating tabbed bar, the X button appears in title bar again. And when I click it, it does not even hide whole window as it should, but it keeps some empty window only with menu in toolbar available. (but I need to remove the X button completely anyway so I don’t need to solve correct hiding)

  5. I had to copy extcontrolbartabbedfeatures.h from /src folder to /include . Is it mistake or intention to have it in your /src folder?


Here is my code:



int CSiteFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CExtNCW<CFrameWnd>::OnCreate(lpCreateStruct) == -1)
        return -1;

    if( ! m_wndView.Create(
            this,
            CRect(0,0,0,0),
            AFX_IDW_PANE_FIRST
            )
        )
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }
    m_wndView.OrientationSet( __ETWS_ORIENT_TOP );
    m_wndView.ShowBtnCloseSet( true );
    m_wndView.ItemDraggingSet();
    m_wndView.CloseOnTabsSet();


    VERIFY(g_CmdManager->ProfileSetup(L"site",GetSafeHwnd())    );


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

    CExtDynamicBarSite::Install( this );
    CExtDynamicBarSite::m_bEnableDndDocumentTabs = true;
    
    CExtCmdIcon icon;
//    CExtDynamicControlBar *m_pBarMain,*m_pBarForm;

//    m_pBarMain = (CExtDynamicControlBar*)CExtDynamicBarSite::BarAlloc(_T("Main"),icon,0,NULL,true);
//    m_pBarForm = (CExtDynamicControlBar*)CExtDynamicBarSite::BarAlloc(_T("Form"),icon,0,NULL,true);
    m_pBarMain = (CMyDynamicControlBar*)CExtDynamicBarSite::BarAlloc(_T("Main"),icon,0,RUNTIME_CLASS(CMyDynamicControlBar),true);
    m_pBarForm = (CMyDynamicControlBar*)CExtDynamicBarSite::BarAlloc(_T("Form"),icon,0,RUNTIME_CLASS(CMyDynamicControlBar),true);

    m_scrMain.Create(m_pBarMain,CRect());
    m_wndMain.Create(CSiteMainDlg::IDD,&m_scrMain);
    
    m_wndForm.Create(CSiteFormDlg::IDD,m_pBarForm);

    m_pBarForm->BarStateSet(CExtDynamicControlBar::__EDBS_DOCUMENT,true);
    m_pBarMain->BarStateSet(CExtDynamicControlBar::__EDBS_DOCUMENT,true);

    return 0;
}

BOOL CSiteFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{

    return __super::OnCreateClient(lpcs, pContext);
}


IMPLEMENT_DYNCREATE(CMyDynamicControlBar,CExtDynamicControlBar);

void CMyDynamicControlBar::OnNcAreaButtonsReinitialize()
{
    ASSERT_VALID( this );
INT nCountOfNcButtons = NcButtons_GetCount();
    if( nCountOfNcButtons > 0 )
        return;
//    NcButtons_Add( new CExtDynamicBarNcAreaButtonClose(this) );
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtDynamicBarNcAreaButtonAutoHide(this) );
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtDynamicBarNcAreaButtonMenu(this) );
}


bool CMyDynamicControlBar::OnInitDbsMenu(
        CExtPopupMenuWnd * pPopup,
        HWND hWndTrack,
        CObject * pHelperSrc,
        LPARAM lParamHelper
        )
{
    bool ret = CExtDynamicControlBar::OnInitDbsMenu(pPopup,hWndTrack,pHelperSrc,lParamHelper);

    INT nPosToRemove = pPopup->ItemFindPosForCmdID( 30384 /* ID_EXT_DYN_BAR_HIDE */ );
    if (nPosToRemove>=0)
        pPopup->ItemRemove(nPosToRemove);

    return ret;
}


CExtDynamicTabbedControlBar * CMyDynamicControlBar::OnDbsCreateTabbedBarInstance() const
{
    ASSERT( this != NULL );
//    CExtDynamicTabbedControlBar * pBar = new CExtDynamicTabbedControlBar;
    CMyDynamicTabbedControlBar * pBar = new CMyDynamicTabbedControlBar;
    return pBar;
}


IMPLEMENT_DYNCREATE(CMyDynamicTabbedControlBar,CExtDynamicTabbedControlBar);

void CMyDynamicTabbedControlBar::OnNcAreaButtonsReinitialize()
{
    ASSERT_VALID( this );
INT nCountOfNcButtons = NcButtons_GetCount();
    if( nCountOfNcButtons > 0 )
        return;
//    NcButtons_Add( new CExtDynamicBarNcAreaButtonClose(this) );
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtDynamicBarNcAreaButtonAutoHide(this) );
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtDynamicBarNcAreaButtonMenu(this) );
}

Technical Support May 25, 2010 - 9:05 AM

You can remove the [X]-button from the document tabs using the CExtTabPageContainerWnd::CloseOnTabsSet() method.
You can start drag-n-dropping of the document tabs in any theme and appropriate bar is switched into the dockable mode. You can dock it anywhere in any theme. But we fixed one issue related to this feature in the latest Prof-UIS 2.90 pre-release version. So, you may need a source code update.
We have several header files in the Src folder. These header files are internal.

Rado Manzela May 25, 2010 - 3:39 AM

I’m sorry, "1. docking markers are still not shown in any theme" was my fault - release build was linked with correct library, but incorrect resources, now this works.


But other issues are remaining, plus 4. has the same problem also with new themes

Technical Support May 21, 2010 - 10:39 AM

The tab page container window is created as the main SDI view window in your app currently supports only two item dragging modes:

1) Dragging items inside the tab page container only (CExtTabPageContainerWnd::ItemDraggingSet()).

2) Dragging a tabbed bar out of the tab page container only (CExtDynamicBarSite::m_bEnableDndDocumentTabs).

The mixed mode with dragging out of the document tabs, dropping into them and docking markers (guide diamonds) in the center of the document area is in our TO-DO list.

Rado Manzela May 21, 2010 - 8:54 AM

I think problem was that I’ve complied prof-uis 2.87 with #define __EXT_MFC_NO_DOCK_MARKERS


Now I’m using complete 2.89 and it works, but there is a bug. When I turn on themes Office2000, Office XP, office 2003, and native XP/Vista/7, when I drag bar out of document mode and release, instead of creating floating bar, the bar disappears.

Technical Support May 21, 2010 - 12:22 PM

Here is how to disable the "x"-button:

http://www.prof-uis.com/prof-uis/tech-support/faq/control-bars.aspx#how-to-remove-the-close-button-x-from-the-control-bar

But in the case of dynamic bars you should use:
1) CExtDynamicControlBar instead of CExtControlBar
2) CExtDynamicTabbedControlBar instead of CExtDynTabControlBar
3) CExtDynamicBarNcAreaButtonClose instead of CExtBarNcAreaButtonClose

You can override the CExtDynamicControlBar::OnInitDbsMenu() virtual method, invoke the parent class method and remove the ID_EXT_DYN_BAR_HIDE menu command. This will disable the Hide menu item.

We confirm the bug with disappeared bars. It’s related to the SDI and tab page container environment only. MDI with/without tabs work OK. To fix it, please update the source code for the following method:

bool CExtDynamicControlBar::OnStartDraggingDocumentTabItem(
            CExtTabWnd * pWndTab,
            LONG nTabItemIndex
            )
{
            ASSERT( this != NULL );
            ASSERT_VALID( pWndTab );
            pWndTab;
            nTabItemIndex;
            if( ! m_bEnableDndDocumentTabs )
                        return false;
            if( ! _DraggingIsEnabled( this ) )
                        return true;
CPoint point;
            if( ! ::GetCursorPos( &point ) )
                        return false;
            if( ! BarStateSet( __EDBS_DOCKED, false ) )
            {
                        ASSERT( FALSE );
                        return true;
            }
bool bShowContentWhenDragging = _IsShowContentWhenDragging();
CPoint ptFloat( point );
            ptFloat.x -= 15;
            ptFloat.y -= 45;
            ASSERT_VALID( m_pDockSite );
            m_pDockSite->ShowControlBar( this, TRUE, TRUE );
            FloatControlBar( ptFloat );
            GetParentFrame()->RecalcLayout();
            OnRepositionSingleChild();
CPoint ptOffset( point );
CRect rcWnd;
            GetWindowRect( &rcWnd );
            ptOffset -= rcWnd.TopLeft();
            _DraggingStart( point, ptOffset );
            if( m_pDockSite->GetSafeHwnd() != NULL && ( ! bShowContentWhenDragging ) )
            {
                        ASSERT_VALID( m_pDockSite );
                        m_pDockSite->ShowControlBar( this, TRUE, FALSE );
            }
            return true;
}