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 » CExtTabPageContainerWnd, CView and CExtToolControlBar Collapse All
Subject Author Date
Rafkat Medvedev Sep 8, 2005 - 4:13 AM

Good time of the day.



In its program use Prof-UIS v2.40 (trial), DocView (SDI), CExtTabPageContainerWnd, several bookmarks, CViews and CExtToolControlBar.



Appeared several questions:



1. As I can place ToolBar not in CMainFrame, but in window of the page TabPageContainer (that is to say in window CView)?



2. When initializing SDI



 CSingleDocTemplate* pDocTemplate;
 pDocTemplate = new CSingleDocTemplate(
  IDR_MAINFRAME,
  RUNTIME_CLASS(CMyDoc),
  RUNTIME_CLASS(CMainFrame), 
  RUNTIME_CLASS(CMyView));
 AddDocTemplate(pDocTemplate);



and accompaniment in CMainFrame::OnCreate TabPageContainer and pages



if( ! m_wndTabPageContainer.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 );
HICON hIconTabCaption = (HICON)
  ::LoadImage(
   ::AfxGetInstanceHandle(),
   MAKEINTRESOURCE(IDR_TOMIS2TYPE),
   IMAGE_ICON,
   16,
   16,
   0
   );
 ASSERT( hIconTabCaption != NULL );



 if(!m_myNewView.Create(
   NULL,
   NULL,
   AFX_WS_DEFAULT_VIEW,
   CRect(0, 0, 0, 0),
   &m_wndTabPageContainer,
   AFX_IDW_PANE_FIRST,
   NULL
   )
  )
 {
  ASSERT( FALSE );
  return -1;
 }
 if(!m_wndTabPageContainer.PageInsert(
   m_mapView.m_hWnd,
   _T("MyNewView"),
   hIconTabCaption,
   false,
   -1, // append
   true
   )
  )
 {
  ASSERT( FALSE );
  return -1;
 }



it is got window CMyView (DocTemplate) located over TabPageContainer and new CView.



As possible delete the window CMyView (DocTemplate) and join new CViews to the document (CDocument)?



Hope on quick and comprehensive answer...



Rafkat

Technical Support Sep 8, 2005 - 9:19 AM

You can create the CExtToolControlBar window and use it as a non-redockable toolbar inside any window, not only inside the main frame window. The ProfUIS_Controls sample application creates several toolbars windows inside dialogs. The tab page container window is always the parent for the tab control and a few other windows (usually resizable dialogs). The latter correspond to the tab items and used as tab pages. You can create a non-redockable toolbar inside any page window inserted into the tab page container. Here are general guidelines on how to create and use non-redockable toolbars:

1) Create a toolbar window in the OnCreate() (or OnInitDialog() in case of the dialog) method and initialize toolbar’s buttons:

    if(   (! m_wndToolBar.Create(
            NULL,
            this,
            AFX_IDW_TOOLBAR,
            WS_CHILD|WS_VISIBLE
                |WS_CLIPCHILDREN|WS_CLIPSIBLINGS
                |CBRS_ALIGN_TOP|CBRS_GRIPPER|CBRS_TOOLTIPS
                |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
            ) )
       || (! m_wndToolBar.LoadToolBar(
            IDR_TOOLBAR_RESOURCE ) )
        )
    {
        ASSERT( FALSE );
        return ...
    }
2) Stick this toolbar to the border of its parent window at the end of OnCreate() (or OnInitDialog() in case of the dialog):
    CWnd::RepositionBars( 0, 0xFFFF, 0 );
3) If the toolbar’s parent window can be resized at run-time, then you should handle the window size change event like as follows:
    void CMainDlg::OnSize( UINT nType, int cx, int cy ) 
    {
        CExtResizableDialog::OnSize(nType, cx, cy);
        if( nType != SIZE_MINIMIZED )
            CWnd::RepositionBars( 0, 0xFFFF, 0 );
    }
Of course, it is possible to destroy the existing view window at run-time just by invoking the DestroyWindow() virtual method, creating another view window and attaching it to the existing document object. Finally you should make a newly created view window active inside its parent frame window. Your code may look like this:
bool CMainFrame::ReCreateTheViewWindow()
{
CView * pOldActiveView = GetActiveView();
    if( pOldActiveView != NULL )
    {
        ASSERT_VALID( pOldActiveView );
        pOldActiveView->DestroyWindow();
    }
CCreateContext context;
    context.m_pNewViewClass = pNewViewClass;
    context.m_pCurrentDoc = GetActiveDocument();
    _cc.m_pCurrentFrame = this;
    _cc.m_pLastView = NULL;
    _cc.m_pNewDocTemplate =
        _cc.m_pCurrentDoc->GetDocTemplate();
    _cc.m_pNewViewClass =
        RUNTIME_CLASS( CYourNewViewWindowClassName );
CView * pNewActiveView = CreateView( &_cc );
    if( pNewActiveView == NULL )
    {
        ASSERT( FALSE );
        TRACE0("Failed to create view window\n");
        return false;
    }
    SetActiveView( pNewActiveView );
    return true;
}

Rafkat Medvedev Sep 9, 2005 - 4:59 AM


Thank you for answer!


But can I use redockable toolbar inside any window?

Technical Support Sep 9, 2005 - 12:05 PM

All Prof-UIS dockable control bars are derived from the MFC’s CControlBar class, which implements a generic redockable bar. The MFC control bars support drag-and-dropping only when created inside the CFrameWnd window. So, this is essential.

Rafkat Medvedev Sep 9, 2005 - 4:57 AM

Ñïàñèáî çà îòâåò!


À ìîãó ÿ èñïîëüçîâàòü redockable toolbar inside any window???