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 » Question about extending sample app PageContainer Collapse All
Subject Author Date
Scott Moore Jan 21, 2009 - 8:35 AM

I’m trying to create an application that is somewhat similiar to your PageContainer sample app.



The thing I want to do differently, is have a window structure like this:



class CMainFrame : public CExtNCW < CFrameWnd >, public CExtDynamicBarSite

    class CTabView : public CExtTabPageContainerWnd

        CExtDynamicControlBar

            CExtResizableDialog

                CInnerToolControlBar   (top toolbar on form)

                CExtControlBar

                    CExtPageContainerWnd

                        CExtGridWnd

                        CExtWFF < CTreeCtrl >

                CExtControlBar

                    <Other Controls>

                CExtResizeableDialog

                    <Other Controls>





The problem is the application hangs trying to create the first CExtControlBar



    CExtControlBar _wndResizableBarLeft;



    if (!(_wndResizableBarLeft.Create(

            NULL,

            this,

            ID_SERVERS_RESIZEABLE_BAR_LEFT,

            WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)

        &&  _wndPages.Create(&_wndResizableBarLeft, (UINT)IDC_STATIC, CRect(0,0,0,0), __EPCWS_STYLES_DEFAULT)

            && _wndGrid.Create(&_wndPages, CRect(0, 0, 300, 300), (UINT)IDC_SERVER_GRID, WS_CHILD|WS_VISIBLE,__ESLW_SMOOTH_SCROLL)

            && _wndTree.Create(WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_INFOTIP|TVS_SHOWSELALWAYS, CRect(0,0,300,300), &_wndPages, (UINT)IDC_STATIC)

            )

        )

    {

        TRACE0("Failed to create page containers\n");

        return -1;        // fail to create

    }



The problem is it gets stuck in an infinite loop here (EXtControlBar.cpp):



    case WM_CREATE:

        {

            if( (!m_bPresubclassDialogMode) && (!IsFixedMode()) )

            {

                ASSERT( GetSafeHwnd() != NULL );

                ASSERT( ::IsWindow(GetSafeHwnd()) );

                HWND hWndParent = ::GetParent( GetSafeHwnd() );

                CFrameWnd * pFrame = NULL;

                do

                {

                    ASSERT( hWndParent != NULL );

                    ASSERT( ::IsWindow(hWndParent) );

                    CWnd * pWnd = CWnd::FromHandle( hWndParent );

                    if( pWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)) )

                    {

                        pFrame = (CFrameWnd *)pWnd;

                        break;

                    }

                } while( pFrame == NULL );





Which is because the CExtControlBar is not a direct child of CMainWnd.  So, it seems I cannot use a CExtControlBar in a dialog, nor can I use a CSplitterWnd.  My question is how can I get similiar child controls as the PageContainer app, but have them inside a CExtDynamicConrolBar?  I would also like a splitter type control where I can adjust the controls on the left and right sides.



Thanks for any help.



Scott

Technical Support Jan 22, 2009 - 12:42 PM

Yes, the CExtControlBar control bars should be created inside frame windows only when the CExtToolControlBar toolbars can be created inside dialog. But toolbars inside dialogs cannot be drag-n-dropped.

After more than 10 years of programming with MFC, we do not see strong differences between frame and dialog windows. If you need window based on the dialog template resource and you also need re-dockable control bars, then you should created main frame window with all the required bars and create dialog window inside it as main view window (just create dialog as visible child of main frame, then invoke pDialog->SetDlgCtrlID( AFX_IDW_PANE_FIRST )).

Scott Moore Jan 21, 2009 - 4:44 PM

UPDATE - I have successfully manager to do this by embedding a CFrameWnd class on my CExtResizeableDlg that is a child of the dynamic bar.


But now my problem is the initial size of the 2 CExtControlBar classes is way too small.  The state saves correctly and restores after I adjust their size, quit the app and restart.  But I really need to set the initial size to something practical.  How do I do that?  The CRect() I pass in to the Create has no effect.


 


    if (!(_wndResizableBarLeft.Create(

            NULL,

            _wndFrame,

            IDC_SERVERS_RESIZEABLE_BAR_LEFT,

            WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)

        &&  _wndPages.Create(&_wndResizableBarLeft, (UINT)IDC_SERVERS_PAGE_CONTAINER_LEFT, CRect(0,0,800,800), __EPCWS_STYLES_DEFAULT|__EPCWS_PAGE_BORDERS)

            && _wndGrid.Create(&_wndPages, CRect(0, 0, 800, 800), (UINT)IDC_SERVER_GRID, WS_CHILD|WS_VISIBLE)

            && _wndTree.Create(WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_INFOTIP|TVS_SHOWSELALWAYS, CRect(0,0,500,500), &_wndPages, (UINT)IDC_SERVER_TREE)

            )

        )

    {

        TRACE0("Failed to create page containers\n");

        return -1;        // fail to create

    }



    if (!(_wndResizableBarRight.Create(

            NULL,

            _wndFrame,

            IDC_NODE_RESIZEABLE_BAR_RIGHT,

            WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)

        && _wndNodeList.Create(&_wndResizableBarRight, CRect(0, 0, 600, 600), (UINT)IDC_NODE_LIST, WS_CHILD|WS_VISIBLE)

            )

        )

    {

        TRACE0("Failed to create page containers\n");

        return -1;        // fail to create

    }

Scott Moore Jan 21, 2009 - 8:55 AM

Update: Just playing around with the code, I did this before the Create()


    _wndResizableBarLeft.m_bPresubclassDialogMode = 1;


Which allows the application to start, but the controls do not display correctly.

Technical Support Jan 22, 2009 - 12:45 PM

We would prefer to create a dialog inside a frame. But creating a frame inside a dialog is ok. Please note, the frame window deletes itself in the CFrameWnd::PostNcDestroy() virtual method. So, you should create a frame window as a dynamic object or override the CFrameWnd::PostNcDestroy() without invoking the parent class method.

Please use the CExtControlBar::SetInitDesiredSizeHorizontal(), CExtControlBar::SetInitDesiredSizeVertical() and CExtControlBar::SetInitDesiredSizeFloating() to set initial desired sizes of the control bar.