engllf
asked on
CSingleDocTemplate
An SDI application has a default CMyAppView generated by MFC. It is modified to have a splitter window. The left pane uses CLeftView and the right pane uses CRightView.
Which view should i use in the document template constructor in the InitInstance() and why?
BOOL CMyApp::InitInstance()
{
//...
// Establish the document type
// supported by the application
AddDocTemplate( new CSingleDocTemplate( IDR_MAINFRAME,
RUNTIME_CLASS( CMyAppDoc ),
RUNTIME_CLASS( CMyFrameWnd ),
RUNTIME_CLASS( ????? ) ) );
// ...
}
TIA
Which view should i use in the document template constructor in the InitInstance() and why?
BOOL CMyApp::InitInstance()
{
//...
// Establish the document type
// supported by the application
AddDocTemplate( new CSingleDocTemplate( IDR_MAINFRAME,
RUNTIME_CLASS( CMyAppDoc ),
RUNTIME_CLASS( CMyFrameWnd ),
RUNTIME_CLASS( ????? ) ) );
// ...
}
TIA
ASKER
Hi,
what is the consequences of i do this?
BOOL CMyApp::InitInstance()
{
//...
AddDocTemplate( new CSingleDocTemplate( IDR_MAINFRAME,
RUNTIME_CLASS( CMyAppDoc ),
RUNTIME_CLASS( CMyFrameWnd ),
RUNTIME_CLASS( CMyAppView) ) ); // neither CLeftView nor CRightView
// ...
}
and
BOOL CMyFrameWnd::OnCreateClien t(LPCREATE STRUCT lpcs, CCreateContext* pContext)
{
...
// create the Left View
if (!m_wndSplitter.CreateView (0,0, RUNTIME_CLASS(CLeftView), size, pContext))
return FALSE;
// Now create the right view
if (!m_wndSplitter.CreateView (0,1,RUNTI ME_CLASS(C RightView) , size,pContext))
return FALSE;
...
}
TIA
what is the consequences of i do this?
BOOL CMyApp::InitInstance()
{
//...
AddDocTemplate( new CSingleDocTemplate( IDR_MAINFRAME,
RUNTIME_CLASS( CMyAppDoc ),
RUNTIME_CLASS( CMyFrameWnd ),
RUNTIME_CLASS( CMyAppView) ) ); // neither CLeftView nor CRightView
// ...
}
and
BOOL CMyFrameWnd::OnCreateClien
{
...
// create the Left View
if (!m_wndSplitter.CreateView
return FALSE;
// Now create the right view
if (!m_wndSplitter.CreateView
return FALSE;
...
}
TIA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good question. I will delete straight away... : )
will need to override CMyFrameWnd::OnCreateClien
In OnCreateClient() you will need to create a static splitter window
with two columns. After creating the splitter window, you can then
create the two views.
Assuming that you used CRightView in your call to AddDocTemplate, then
you OnCreateClient will be similar to:
BOOL CMyFrameWnd::OnCreateClien
{
CRect rect;
GetClientRect(&rect);
int width = rect.Width()/2;
int height = rect.Height();
CSize size(width, height);
// create static splitter with 1 row and 2 columns
if ( !m_wndSplitter.CreateStati
return FALSE;
// create the Left View
if ( !m_wndSplitter.CreateView(
return FALSE;
// Now create the right view
if ( !m_wndSplitter.CreateView(
return FALSE;
return TRUE;
}