Using the MFC Migration Tool

Once your C code is as clean as possible, use the MFC migration tool to learn more about the migration issues that apply to your program.

The MFC migration tool, MIGRATE.EXE, examines your code, file by file, against a database of porting guidelines. For example, if you open SHOWDIB.C with MIGRATE.EXE, you can step through the migration issues in the .C file. The tool tells you, for instance, that "WinMain is not needed in an MFC Application" and tells you where to move pertinent WinMain code in the MFC framework.

The tool steps through your code, highlighting issues. You can use the tool to do simple editing of your source code, and it can make some simple changes, but only under your direction. The tool will identify potential problem areas in your C source code and give you advice towards cleaning it up. MIGRATE.EXE is a standalone tool that works in conjunction with your C++ development environment (for example, Visual C++). You should do major migration changes and significant source code editing, as well as compiling and debugging the resulting application, from within your C++ development environment.

The main issues you are likely to find when you use the migration tool are listed in Issues Shown by the Migration Tool. This guide is available as a Help file that you can access from the tool.

Note The MFC migration tool also comes with an additional database, C16_C32.PT, use when you migrate your code from 16 bit to 32 bit as well.

Þ To use the MFC migration tool on your C files

1. Run MIGRATE.EXE.

2. Use the Open command on the File menu to open the file for which you want migration information.

The tool is an MDI application, so you can have multiple files open at once.

3. Use the Set Migration Options command on the Migrate menu and select one or more of the categories listed in the dialog box. Choose OK when you finish.

Tip For migration to MFC, select each of the Phases listed in the Migration Options dialog box in turn. That is, work through Phase 1 before you examine the issues for Phases 2 and 3.

You can double-click an option in the dialog box to toggle whether it is marked or not.

To include an option, select it with the mouse or keyboard and choose the Mark button.

To remove an option, select it with the mouse or keyboard and choose the Unmark button.

4. Use the Migrate Current File command on the Migrate menu to examine migration issues in the opened file.

5. In the Migrating dialog box, note the first migration issue on display in the edit boxes.

The item that triggered the issue is highlighted in your source file window.

The upper box in the Migrating dialog box describes the potential problem; the lower box tells you in general terms what to do about it or suggests some replacement C++ code. If you agree with the suggested replacement C++ code, you can choose the Replace button to replace the highlighted C code with the replacement code and continue the search.

When the tool finds an issue, you can use the Help button to display the appropriate help topic in the online version of the MFC Migration Guide.

6. After viewing a migration issue, choose the Continue button to display the next issue.

7. Repeat steps 2 through 6 for each file in your project.

The MFC migration tool uses porting database files (files with a .PT extension). These are simple text files containing blocks of information used to scan your code and display issues during the migration process.

Tip The migration tool has editing capabilities, so you can make simple code changes directly as you are examining your files.