How to mix two major Application Framework VCL & MFCs below C Builder 3.0?
Mixing VCL and MFC is indeed a good choice, but relative, your program complexity will increase. In this first assume that you have seen this article "How to compile the MFC program in C Builder 3.0". Therefore, some basic knowledge is not repeated. In order to discuss this topic, I decided to use the examples of the way to explain: Step 1. First use the method you know to create an empty, and you can correctly compile the MFC's Project (you can refer to "How to in C Builder 3.0 compiles the program containing the MFC. "This article). In this first, it is assumed that this Project name is Project1, while MainForm is Form1, MainForm file is Unit1.cpp, which is generated by BCB 3.0 as default, so you should have the following files:
Project1.bprproject1.cppUnit1.cppunit1.hunit1.dfm
Step 2. In this example, I decided to use two MFC categories (Class) to mix C Builder's VCL, and these two categories are CFiledialog and CPOINT. OK, I know these, let's first design some things on Form use the MFC category! Put two Label components and a Button component Step 3.Thim, it is to start joining the MFC code you want, but before this, you must first use the announcement file used by the MFC to add: // --- -------------------------------------------------- ---------------------- # include
You may think that you can use the X and Y I have passed directly, why bother to use the cpoint category? Hey, if you don't do this, how to express MFC and VCL mix? STEP 5. Well, then we will come to the CFILEDIALOG category to create an OnClick Event on the BCB, add the following: void __fastcall tform1 :: button1click (Tobject * sender) {cfiledialog DLG (True , "CPP", "*. CPP", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T ("C Source File (* .cpp)")))))); if (DLG.Domodal () == iDok) {label2-> caption = (ANSISTRING) Dlg.getPathname ();}}, you get a lot of Warning when compiling, but after compiling, press this button you will get the same picture as the TopEndialog class in the VCL, when you choose Form Label2 will also be replaced with the name of the file you selected, so that CFiledialog and VCL mix are also the same. In this example, you can learn MFC and VCL mix. However, some of the problems that have left will wait for solving, such as how should Warning when compile? In my habit, I won't let the compiler tell me any warning. How to solve it? Smart readers, moving brain!