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

  • When it comes to desktops – physical or virtual – it's all about the applications. Cloud-hosted virtual desktops are growing fast because you get local data center-class security and 24x7 access with the complete personalization and flexibility of your own desktop. Organizations make five common mistakes when it comes to planning and implementing their application management strategy. This eBook tells you what they are and how to avoid them, and offers real-life case studies on customers who didn't …

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds