Well ummm. This is why I asked because I have down loaded sample code from
Doc class. The other thing is Dan mentioned that "CListFrame is a generic
Scott McPhillips [MVP] wrote:
"Al" <Al@discussions.microsoft.com> wrote in message
news:F7AF2E8C-75A8-4498-9C0C-8D8FFB4214A1@microsoft.com...
I guess what I am trying to say is if I have a SDI, explorer style,
docoment
view archetecture and I want to replace the right hand view with a
different
view from making a selection from the main menu or from a selection
from the
tree control in the left view, where would I add code to make that
happen?
Would it be in one class or 2? And which classe(s) would be correct
one(s)?
The splitter window is a member of the CMainFrame and is a child window
of CMainFrame. The CMainFrame receives menu/toolbar commands and
creates the splitter and its child panes. So this is logically where the
action should be to replace the right hand view in the splitter. You
would add a handler for the menu command in the CMainFrame and switch
the view in or from that function.
Since you also want to initiate the view switch from something in the
left view, the left view can use AfxGetMainWnd() to call a CMainFrame
function to do the job.
I have, in the past, created a derived splitter class that can be
instantiated/controlled from a doc. Why? Because I learned it here. It
goes something like this (CListFrame is a generic multiview SDI frame)
Point is, with the right kind of splitter, you don't have to ask the
main frame to do it. But, this may take some practice as I recall.....
if bar < 5, it was a first time call..... (Hi Joe, no good reason for
'5' as I recall other than I did not want the client to completely
collapse on save and first time use......)
void CMathDoc::OnMathContributionTables( )
{
CListFrame* pFrame= DYNAMIC_DOWNCAST( CListFrame, AfxGetMainFrame( ) );
ASSERT_VALID( pFrame );
POSITION pos= GetFirstViewPosition( );
if( ! pos )
return;
if( ! bInSplit )
{
pProjection= DYNAMIC_DOWNCAST( CLView, GetNextView( pos ) );
ASSERT_VALID( pProjection );
CSplitterView* pSView= CreateSplitter( pFrame, 1, 2, this,
_T("AssessmentSplitter") );
ASSERT_VALID( pSView );
CLMView* pLView= DYNAMIC_DOWNCAST( CLMView, pSView->MoveFrameView( 0,
0 ) );
ASSERT_VALID( pLView );
AfxSaveWinPos( pLView );
pLView->SetExListStyles( LVS_NOSCROLL );
pLView->SetListStyles( 0, LVS_NOSCROLL );
pLView->LockWindowUpdate( );
CView* pTList= pSView->CreateView( 0, 1, RUNTIME_CLASS( CLAssessView
), this );
ASSERT_VALID( pTList );
CLAssessView* pTestList= DYNAMIC_DOWNCAST( CLAssessView, pTList );
pTestList->UpdateCalc( );
AfxGetWinPos( _T("ProjectionAssessment"), pLView );
int bar, min;
pSView->GetSplitterWnd( )->GetColumnInfo( 0, bar, min );
if( bar < 5 )
{
WINDOWINFO winInfo;
pFrame->GetWindowInfo( &winInfo );
pSView->GetSplitterWnd( )->SetColumnInfo( 0, ( winInfo.rcClient.right
- winInfo.rcClient.left ) * 3 / 4, 5 );
}
pFrame->RecalcLayout( );
md->ShowWindow( SW_HIDE );
pLView->UnlockWindowUpdate( );
pLView->Invalidate( );
bInSplit= true;
}
else //in splitter
{
CView* pLView= pFrame->FindViewByRuntimeClass( RUNTIME_CLASS( CLMView ) );
ASSERT_VALID( pLView );
pLView->LockWindowUpdate( );
AfxSaveWinPos( pLView );
CView* pTest= pFrame->FindViewByRuntimeClass( RUNTIME_CLASS(
CSplitterView ) );
ASSERT_VALID( pTest );
CSplitterView* pSView= DYNAMIC_DOWNCAST( CSplitterView, pTest );
ASSERT_VALID( pSView );
pSView->DestroyWindow( );
AfxGetWinPos( _T("mathViewProj"), pLView );
pLView->UnlockWindowUpdate( );
md->ShowWindow( SW_NORMAL );
pFrame->SetFocus( );
bInSplit= false;
}
}