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)

This entry was posted in tech. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>