How to compiler the program with MFC classes in BCB 3.0 ?
1998-04-23 12:21:36

Even C++Builder 3.0 is the next version for Borland C++ 5.02, and it support MFC too. But it is not easy to use MFC classes in BCB 3.0. It is as easy as just write down MFC native code and check the MFC Compatibility in Project Option. If you just done in this way, I promise that you will got lots of Warring and Error from the compiler.

How to make it more easyer. No way! We must do it by yourself, and you can make this project be the template one. You can put this project to the Object Respository. In this way, you can enjoy you MFC road in BCB 3.0 by just clicking the new in the menu and click the project you made.

That as make it step by step :

Step 1 :

Click the new appliction in main menu.

Step 2 :

Add these compiler flags in the "Conditionals\Conditional defines" section of the "Directories\Conditionals" page in Project Option :


And remember to add "$(BCB)\include\MFC" in the "include path" section.

Step 3 :

Check the "MFC Compatibility" in the "Advance Compilers" section.

Step 4 :

Then, open the makefile (.BPR file). Find out "CFLAG1 = ...." this line, and change this line to be :
CFLAG1 = -Od -Hc -w -k -r- -y -v -vi- -c -w-par -w-inl -w-hid -w-aus -g0 -WM -W

Then, find out "CFLAG3 = ......" this line, and change this line to be :
CFLAG3 = -Tkh30000 -VF

At last, find out "ALLLIB = .... " this line, and change this line to be:
ALLLIB = $(LIBFILES) $(LIBRARIES) nafxcw.lib import32.lib cw32mt.lib

Then , save this file right now.

Step 4 :
In this simple way, You can enjoy the MFC in BCB3!

Something that you should know

In this example, the EXE file was linked as static link, not the dynamic one. How to make a dynamic one with MFC DLL in BCB 3? Use the source Luke, just look the MFC examples in BCB3, you can find out the answer.

In additional, there are many ways to combine VCL and MFC together, in my opinion there can be two main way approximately :

1. Use the TApplication be the main body, and use the VCL and MFC classes together, like Cpoint, CFile , TOpenDialog, etc. . (see another article : How to combine the program with MFC classes in BCB 3.0 ?)

2. Use the MFC class CApp as main class, and call the Forms builded by VCL from menu.

How to do these two programs in BCB3 ? Wise reader, use you brain to find out!