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 » CSplitterWnd to CExtTabPageContainerWnd : Conversion Collapse All
Subject Author Date
SANKET DAS Jun 25, 2007 - 1:31 AM

We have an application, where there are three splitter windows being loaded at runtime on the MainFrame window.Now we wish to make our application mainframe a tabbed container using profuis. Could you plz help us on this. Do we just need to inherit our window class from the CExtTabPageContainerWnd and use its corresponding methods.Kindly suggest.

SANKET DAS Jul 4, 2007 - 9:42 AM

If we miss out making the main view, then RecalcLayout is failing.

Technical Support Jul 5, 2007 - 9:41 AM

Would you send us a test project which demonstrates the problem?

SANKET DAS Jul 4, 2007 - 9:39 AM

Thanks for the project, but in the member of CChildView class, how can we create its object before the CCreateClient method.Because in the same view cannot be created twice.

Suhai Gyorgy Jul 5, 2007 - 2:27 AM

Actually best would be if you could make a stripped-down version of your project, showing only the very basics of the doc-view structure and their initializations.

Suhai Gyorgy Jul 5, 2007 - 2:23 AM

Ok, I think I misunderstood you. From what you’re saying I assume now that you have a CSingleDocTemplate or a CMultiDocTemplate created in your application class’ InitInstance, which results in calling MainFrame’s OnCreateClient.
Would you show that code, too? Are you attaching all the view classes to the same doc class?

SANKET DAS Jul 5, 2007 - 12:36 PM

Actually we have a MainFrame class. In the OnCreate() method of MainFrame, the first line of code actually calls the CMainFrame::OnCreateClient().But the biggest issue is this Oncreateclinet creates the splitter windows and puts the views in it. As you had suggested, I creatd a childview, and creted the three views in it that we have. Next they were moved into a tabbed container. As the first line in CMAinFrame::OnCreate(), now I create this tabbed container and then go on to add other things like toolbar, menubar etc.

While debugging it out, I found that the crashes are occurring not at creation on the MainFrame but while referrring to those views which we had created in the ChildView class. Our application has three splitter windows on a mainframe, other details can be avoided.I may be making mistakes in making the views rect correct, but how cn i rectify it? The application simply doesnt open at all after these changes. kindly suggest

SANKET DAS Jul 3, 2007 - 1:37 AM

Following is the
code for the method OnCreateClient() in my MainFrame... Kindly suggest. The commented part contains the implementation of the earlier splitterwnd class.

// Normal processing.
//6.5 UI Enhancement
/*CWinApp * pApp = ::AfxGetApp();
    ASSERT( pApp != NULL );
    
    HICON hIcon = pApp->LoadIcon( IDR_MAINFRAME );
    ASSERT( hIcon != NULL );
    SetIcon( hIcon, TRUE );
    SetIcon( hIcon, FALSE );

    ASSERT( pApp->m_pszProfileName != NULL );
    g_CmdManager->ProfileSetup(pApp->m_pszProfileName,GetSafeHwnd());*/
//6.5 UI Enhancement

HINSTANCE hInstResource =AfxFindResourceHandle(MAKEINTRESOURCE( IDR_MAINFRAME ),
RT_GROUP_ICON);
ASSERT( hInstResource != NULL );
HICON hIcon = (HICON)::LoadImage(hInstResource,MAKEINTRESOURCE( IDR_MAINFRAME ),
IMAGE_ICON,16,16,0);
ASSERT( hIcon != NULL );
SetIcon( hIcon, FALSE );

CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );

//The command manager is a key global object in Prof-UIS. Registering the commands in it.
// is neccesary .This needs to be done at CMainFrame::OnCreate () method:
g_CmdManager->ProfileSetup(pApp->m_pszProfileName,GetSafeHwnd());

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


try
{
//6.5 UI Enhancement. Commented this code
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
SAIS_E_MAINFRM_CREATE_CLIENT_SPLITTER);
}

// add the first splitter pane - the Bins View in column 0
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSaIsBinsView),
CSize(200, 50), pContext))
{
throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
SAIS_E_MAINFRM_CREATE_CLIENT_BINS_VIEW);
}
    
//6.5 UI Enhancement
// add the second splitter pane - which is a nested splitter with 2 rows
if (!m_wndArenaSplitter.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd column of first splitter
))
{
throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
SAIS_E_MAINFRM_CREATE_CLIENT_ARENA_SPLITTER);
}

     if (!m_wndArenaSplitter.CreateView(1, 0, RUNTIME_CLASS(CSaIsPresentationView),
CSize(100, 100), pContext))
{
throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
SAIS_E_MAINFRM_CREATE_CLIENT_PRES_VIEW);
}

// now create the two views inside the nested arena splitter

//UI Enhancements 2005
    if(! m_wndTabbed.Create(this,CRect(0,0,0,0),UINT( IDC_STATIC ),WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS ,NULL))
     {
     throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
SAIS_E_MAINFRM_CREATE_CLIENT_SPLITTER);
     }
        
     //begin with plan navigator

CRuntimeClass * pRTC = RUNTIME_CLASS( CSaIsPlanNavigatorView );
CView * pNormalNavView = STATIC_DOWNCAST( CView, pRTC->CreateObject());

     if( !pNormalNavView->Create(::AfxRegisterWndClass(0),_T(""),WS_CHILD | WS_VISIBLE,
         CRect(0,0,0,0),this,AFX_IDW_PANE_FIRST,NULL))
{
TRACE0("Failed to create view window\n");
ASSERT( FALSE );
return -1;
}

CSaIsPlanNavigatorView * pNavView = STATIC_DOWNCAST( CSaIsPlanNavigatorView, pNormalNavView );

     VERIFY(m_wndTabbed.PageInsert(pNavView,_T("PlanNavigator"),NULL,TRUE));

//now start with planeditor.Thats what ProfUI team
     //suggested.
CRuntimeClass * pEditRTC = RUNTIME_CLASS( CSaIsPlanEditorView );
CView * pNormalEditView = STATIC_DOWNCAST( CView, pEditRTC->CreateObject());

     if( !pNormalEditView->Create(::AfxRegisterWndClass(0),_T(""),WS_CHILD | WS_VISIBLE,
         CRect(0,0,0,0),this,AFX_IDW_PANE_FIRST,NULL))
{
TRACE0("Failed to create view window\n");
ASSERT( FALSE );
return -1;
}

CSaIsPlanEditorView * pEditView = STATIC_DOWNCAST( CSaIsPlanEditorView, pNormalEditView );

VERIFY(m_wndTabbed.PageInsert(pEditView,_T("PlanEditor"),NULL,FALSE));

     m_wndTabbed.SelectionBoldSet();
m_wndTabbed.OrientationSet(__ETWS_ORIENT_TOP);


    //UI Enhancements 2005

// The first view is another nested splitter.
//if (!m_wndVFLSplitter.CreateStatic(&m_wndArenaSplitter, // our parent is the arena splitter
// 1, 2, // the new splitter is 1 row, 2 columns
// WS_CHILD | WS_VISIBLE | WS_BORDER,
// m_wndArenaSplitter.IdFromRowCol(0,0) // first row,
// //first column of the arena splitter
// ))
//{
// throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
// SAIS_E_MAINFRM_CREATE_CLIENT_VFL_SPLITTER);
//}

/* if (!m_wndArenaSplitter.CreateView(1, 0, RUNTIME_CLASS(CSaIsPresentationView),
CSize(100, 100), pContext))
{
throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
SAIS_E_MAINFRM_CREATE_CLIENT_PRES_VIEW);
}*/

//// now create the two views inside the nested VFL splitter

//if (!m_wndVFLSplitter.CreateView(0, 0, RUNTIME_CLASS(CSaIsPlanNavigatorView),
// CSize(0, 0), pContext))
//{
// throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
// SAIS_E_MAINFRM_CREATE_CLIENT_PLANAV_VIEW);
//}

//if (!m_wndVFLSplitter.CreateView(0, 1, RUNTIME_CLASS(CSaIsPlanEditorView),
// CSize(100, 100), pContext))
//{
// throw new CSa_Exception(SAIS_CAT_INTERNAL_ERROR,
// SAIS_E_MAINFRM_CREATE_CLIENT_PLANED_VIEW);
//}

// Successful return.

return TRUE;
}

Suhai Gyorgy Jul 3, 2007 - 6:39 AM

The very first problem is, that when changing from Splitter to TabPageContainerWnd, you should not write your code inside CMainFrame::OnCreateClient anymore, but inside OnCreate instead. Moreover, your CChildView should be derived from CExtTabPageContainerWnd class and views should be created in OnCreate of CChildView.

You can see a good example of how CExtTabPageContainerWnd should be used, in SimpleGrids sample. But since in that sample the views are not created dynamically, I created a little sample project for you by pretty much simplifying the original SimpleGrids sample. You can download it from here.

The other problem in your code is that you’re creating all views with the same AFX_IDW_PANE_FIRST ID. Those IDs should differ for every view created.

SANKET DAS Jul 3, 2007 - 12:42 AM

The menubars and toolbars in my app already are profui enabled. Can u help me in making the client frames which are part of the application. Need to convert the splitters to tabwindows.

following is the profile setup code we use.

HINSTANCE hInstResource =AfxFindResourceHandle(MAKEINTRESOURCE( IDR_MAINFRAME ),
RT_GROUP_ICON);
ASSERT( hInstResource != NULL );
HICON hIcon = (HICON)::LoadImage(hInstResource,MAKEINTRESOURCE( IDR_MAINFRAME ),
IMAGE_ICON,16,16,0);
ASSERT( hIcon != NULL );
SetIcon( hIcon, FALSE );

CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );

//The command manager is a key global object in Prof-UIS. Registering the commands in it.
// is neccesary .This needs to be done at CMainFrame::OnCreate () method:
g_CmdManager->ProfileSetup(pApp->m_pszProfileName,GetSafeHwnd());

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

Getting crashes in RecalcLayout()...

SANKET DAS Jun 29, 2007 - 7:23 AM

I find no method asynchronous with CreateView. There fore my app opens as a blank frame.

SANKET DAS Jun 28, 2007 - 9:25 AM

We dont need the splitter windows any more and are looking to replace them with tabbed windows on our main frame. Now how can we replace individual splitter windows with one tabbed window and then have the earlier splitter windows as pages in the tabbed window.

We use CSplitterWnd.CreateView() to insert runtime classes which we display on the Cspliter window. Is ur suggestion enough for this?

Please help

Technical Support Jun 29, 2007 - 11:09 AM

Here is how you can create a CView object dynamically:

 CRuntimeClass * pRTC = RUNTIME_CLASS( CYourView );
 CView * pView = STATIC_DOWNCAST( CView, pRTC->CreateObject() );
 
 if( !pView->Create(
   ::AfxRegisterWndClass(0), 
   _T(""), 
   WS_CHILD | WS_VISIBLE, 
   CRect(0,0,0,0), 
   pWndParent, 
   AFX_IDW_PANE_FIRST, 
   NULL
   )
  )
 {
  TRACE0("Failed to create view window\n");
  ASSERT( FALSE );
  return -1;
 }

CYourView  * pYourView = STATIC_DOWNCAST( CYourView, pView );
Then, having the pYourView pointer, you can insert the view into the tab page container.

Technical Support Jun 27, 2007 - 12:39 PM

Yes, you should create the CExtTabPageContainerWnd container window as the parent window for you splitter windows. Having created the splitter window, you can insert it into the CExtTabPageContainerWnd container by using PageInsert().