Checking for Phase 1 Leftovers

If you did everything correctly in Phase 1, the only leftover issues are possibly the following:

Window Registration Calls Outside WinMain

You can search your original C source files for calls to RegisterClass. If any of these calls were for windows that now are equivalent to the CMainFrame and view classes, these calls should have gone away. Otherwise, you can leave them as they are. After all, migration to C++ focuses on those parts of your application that have counterparts in the MFC framework, such as the main frame window and the view (client area). Much of your code should need no further migration, aside from converting C to C++ syntax. For example, if you have a child window that is now a child window of the view (such as a control window of your own) you shouldn't need to do anything to the code for that window, including its WndProc.

Calls to DefWindowProc and Other Non-MFC Functions

Once you've turned your application into an MFC application, you don't need to call DefWindowProc yourself. MFC's message map mechanism ensures that MFC handles any messages that you don't handle.

As you'll see later, in Using the MFC Message Map, MFC applications don't usually use WindowProc and a giant switch statement to handle Windows-based messages. Instead, message handling code is normally placed in separate message handler functions (one per message). MFC calls these class member functions through their class's message map. When you create a handler function for a message, your handler overrides a version defined in your class's MFC base class. Instead of calling DefWindowProc to handle messages that you don't handle, you typically call the base-class version of the handler function, something like this:


void CShowDibView::OnTimer(UINT nIDEvent) { // your code to handle WM_TIMER // then call the base-class version of OnTimer CView::OnTimer(nIDEvent); }

Notice that your WindowProc function calls CView::WindowProc at the end. In a message handler such as OnTimer, this gives MFC a chance to do its own processing (if any) for the message. In the case of WindowProc, calling the base class lets MFC handle any unhandled messages.