Using MVC in MFC Applications

The MVC classes are designed to be general-purpose and can be incorporated into your MFC application in any number of ways. You could, for example, use MVC alone, as an alternative to the document/view architecture. You could also use parts of MVC to take advantage of its reuse potential. You can use as much or as little MVC in your application as you find appropriate and even mix it with document/view based code.

In an MVC triad, you have three primary parts that you need to integrate into your new or existing application. The model is usually integrated via containment into the document class. The viewport is usually integrated via containment into the window or CView-derived class. Lastly, the controller is normally instantiated by the viewport it controls. The remainder of this section describes the steps required to incorporate an MVC triad into your application.