Converting a CDialog to a CFormView

Back To Tips Page

You have just learned about CFormView.  You want to convert a dialog (perhaps your dialog from your old dialog-based app) to be a CFormView, without having to rewrite everything.

This essay is based on a couple assumptions:


By the time we are finished, you should see how we can extend this to multiple documents, views, etc.

Converting a dialog-based app to a CFormView-based SDI or MDI app

To convert a dialog-based app to an SDI or MDI CFormView-based app, first generate an app with a CFormView.  Move the projectView.h and projectView.cpp files to some other directory, and copy your oldprojectdlg.h and oldprojectdlg.cpp files over as the names proejctView.h and projectView.cpp files.

Open them up, and replace the class name with CprojectView as the class name; so if your dialog class was called CMyDlg it is renamed as CprojectView.

Note the name of the dialog of your CFormView class, such as IDR_PROJECTTYPE.  Write this down somewhere.

Delete the dialog from your SDI/MDI project.

Copy the dialog from your old project to your new project.

Rename it to the name that been used, such as IDR_PROJECTTYPE

Now proceed to the Common Conversion Section

Creating a CFormView-based additional view for a document

DO NOT call AddDocTemplate on this template!!!

Now proceed to the Common Conversion Section

Common Conversion (no matter which way you started)

Compile and execute it.

[Dividing Line Image]

The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.

Send mail to with questions or comments about this web site.
Copyright 2007 FlounderCraft Ltd./The Joseph M. Newcomer Co. All Rights Reserved
Last modified: May 14, 2011