?
Solved

CSingleDocTemplate

Posted on 1998-02-20
4
Medium Priority
?
585 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:engllf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:mulenga
ID: 1316459
You can use either CLeftView or CRightView, it doesn't matter since you
will need to override CMyFrameWnd::OnCreateClient().

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::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
    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.CreateStatic(this, 1, 2, WS_CHILD|WS_VISIBLE ) )
        return FALSE;

    // 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, pContext->m_pNewViewClass, size, pContext ) )
        return FALSE;

    return TRUE;
}
0
 

Author Comment

by:engllf
ID: 1316460
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::OnCreateClient(LPCREATESTRUCT 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,RUNTIME_CLASS(CRightView), size,pContext))
      return FALSE;

   ...
}

TIA
 
0
 

Accepted Solution

by:
smithc earned 40 total points
ID: 1316461
It won't matter at all.  I have a similar application and I have
tried it with and without using the "passed in context".  The code that you have written should work. One question: Why would you pass in a view that you don't plan on using?
0
 

Author Comment

by:engllf
ID: 1316462
Good question. I will delete straight away... : )
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question