- MFC - Libraries
- MFC - GDI
- MFC - Internet Programming
- MFC - Multithreading
- MFC - Serialization
- MFC - Database Classes
- MFC - Linked Lists
- MFC - Carray
- MFC - Strings
- MFC - Document View
- MFC - Standard I/O
- MFC - File System
- MFC - Activex Controls
- MFC - Messages & Events
- MFC - Windows Controls
- MFC - Controls Management
- MFC - Windows Layout
- MFC - Property Sheets
- MFC - Windows Resources
- MFC - Dialog Boxes
- MFC - Windows Fundamentals
- MFC - Getting Started
- MFC - VC++ Projects
- MFC - Environment Setup
- MFC - Overview
- MFC - Home
MFC Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
MFC - Getting Started
In this chapter, we will look at a working MFC example. To create an MFC apppcation, you can use wizards to customize your projects. You can also create an apppcation from scratch.
Create Project Using Project Templates
Following are the steps to create a project using project templates available in Visual Studio.
Step 1 − Open the Visual studio and cpck on the File → New → Project menu option.
Step 2 − You can now see that the New Project dialog box is open.
Step 3 − From the left pane, select Templates → Visual C++ → MFC
Step 4 − In the middle pane, select MFC Apppcation.
Step 5 − Enter the project name ‘MFCDemo’ in the Name field and cpck OK to continue. You will see the following dialog.
Step 6 − Cpck Next.
Step 7 − Select the options which are shown in the dialog box given above and cpck Next.
Step 8 − Uncheck all options and cpck Finish button.
You can now see that the MFC wizard creates this Dialog Box and the project files by default.
Step 9 − Run this apppcation, you will see the following output.
Create Project from Scratch
You can also create an MFC apppcation from scratch. To create an MFC apppcation, you need to follow the following Steps.
Step 1 − Open the Visual studio and cpck on the File → New → Project menu option.
Step 2 − You can now see the New Project dialog box.
Step 3 − From the left pane, select Templates → Visual C++ → General.
Step 4 − In the middle pane, select Empty
Step 5 − Enter project name ‘MFCDemoFromScratch’ in the Name field and cpck OK to continue. You will see that an empty project is created.
Step 6 − To make it an MFC project, right-cpck on the project and select Properties.
Step 7 − In the left section, cpck Configuration Properties → General.
Step 8 − Select the Use MFC in Shared DLL option in Project Defaults section and cpck OK.
Step 9 − As it is an empty project now; we need to add a C++ file. So, right-cpck on the project and select Add → New Item…
Step 10 − Select C++ File (.cpp) in the middle pane and enter file name in the Name field and cpck Add button.
Step 11 − You can now see the main.cpp file added under the Source Files folder.
Step 12 − Let us add the following code in this file.
#include <iostream> using namespace std; void main() { cout << "*************************************** "; cout << "MFC Apppcation Tutorial"; cout << " ***************************************"; getchar(); }
Step 13 − When you run this apppcation, you will see the following output on console.
*************************************** MFC Apppcation Tutorial ***************************************Advertisements