Multiple views for a single document (MDI) 2

I think there is a new/simpler way to create new views attached to an existing document using VC++ 5.0. I think it is a cleaner implementation since it uses new hooks that MFC provides rather than having to work with the CCreateContext's.

Assuming the following are already declared in the app:

CMultiDocTemplate * m_pTemplate;
CWhateverDocument * m_pDocument;

The app would only need to have the following to create a new view attached to the document:

void CWhateverApp::OnCreateView()
{
    // creates the frame and associated view, attaches to document
    CFrameWnd * pFrameWnd = m_pTemplate->CreateNewFrame( m_pDocument, NULL );

    // error checking in case creation of frame or view fails
    RETURN_ON_NULL( pFrameWnd );

    // let the frame do any initialization the framework needs,
    // call the view's OnInitialUpdate()
    m_pTemplate->InitialUpdateFrame( pFrameWnd, m_pDocument );
}



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • New IT trends to support worker mobility — such as VDI and BYOD — are quickly gaining interest and adoption. But just as with any new trend, there are concerns and pitfalls to avoid.  Download this paper to learn the most important considerations to keep in mind for your VDI project.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds