An Overview of MFC, Part 1 - Building our First Application
(Page 5 of 5 )
Just fire up VC++ and to create a new project; choose the File | New option in the File menu. Next, under the Projects tab, highlight Win32 Application. In the Location field type an appropriate path name or click the Browse button. Type in the word "HelloWorld" for the project name, and you will see that word echoed in the Location field as well. Click the OK button to get to the next window. Here, use the default selection "An empty project" and click "Finish" to see an info Dialog. Finally click "OK" to generate the workspace for the application code. You may copy and paste the above code or type it in yourself in a Cpp file that you create by selecting File | New and C/C++ source file on the Files tab. You can name the file whatever you want it to be.
Also, you must now tell the compiler to use the MFC library. If you forget this step the project will not compile and link properly, and error messages will pop up. Choose the Settings option in the Project menu. Next on the General tab, in the Microsoft Foundation Classes combo box, choose the third option: "Use MFC in a Shared DLL" as shown below and then close the dialog by clicking OK.

Figure 1: Telling the compiler to use MFC
Now, to run the application press F5 or Ctrl + F5 and you shall see a window like the one below.

Figure 2: Our First Application
Conclusion
In this tutorial you looked at what MFC is and what benefits it provides over C/SDK programming. We also successfully compiled and executed our first “Hello World” program. In next part we’ll get into understanding structure of MFC programs and how the user interface is separated from the application’s business logic.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |