MFC: Create a resource-based default frame view

CMyFrame is a CFrameWnd created with class wizard
CMyView is a CFormView created with the class wizard

I want CMyFrame to always incorporate CMyView as the view. Make sure MyFrame.cpp includes MyView.h


bool CMyFrame::LoadFrame(..., CCreateContext* pContext)
{
 CCreateContext ctxt;
 if (pContext == 0)
 {
  ctxt.m_pNewViewClass = RUNTIME_CLASS(CMyView);
  pContext = &ctxt;
 }
 if (CFrameWnd::LoadFrame... (the rest is created by the wizard)
}

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*