Skip to main content

The Framework

Instead of creating an application using "raw" Win32 classes and functions, the MFC library simplifies this process by providing a mechanism called the framework. The framework is a set of classes, functions, and techniques used to create an application as complete as possible with as few lines of code as possible. To provide all this functionality, the framework works behind the scenes with the CWinApp class to gather the necessary MFC classes and functions, to recognize and reconcile the Win32 classes that the application needs. This reconciliation is also made possible by a set of global functions. These functions have names that start with Afx... Some of these functions are:
  • AfxFormatString1
  • AfxFormatString2
  • AfxMessageBox
  • AfxFreeLibrary
  • AfxGetApp
  • AfxGetAppName
  • AfxGetInstanceHandle
  • AfxGetMainWnd
  • AfxGetResourceHandle
  • AfxInitRichEdit
  • AfxLoadLibrary
  • AfxMessageBox
  • AfxRegisterWndClass
  • AfxSocketInit
  • AfxSetResourceHandle
  • AfxRegisterClass
  • AfxBeginThread
  • AfxEndThread
  • AfxGetThread
  • AfxWinInit
We will come back to some of these functions and we will see many other MFC macros in later lessons.

Comments

Popular posts from this blog

Creating a Resource

Although an application can use various resources that behave independently of each other, these resources are grouped into a text file that has the .rc extension. You can create this file manually and fill out all necessary parts but it is advantageous to let Microsoft Visual C++ create it for you. To start creating the resources: On the main menu, you can click Project -> Add Resource... In the Solution Explorer, you can right-click the name of the project, position the mouse on Add, and click Resource... Any of these actions would display the Add Resource dialog box. From this dialog box, you would select the type of resource you want and click New (or Import...). You will then be expected to design or customize the resources. Throughout our lessons, we will see various examples. After creating or designing a resource, you must save it. In most cases, you can try closing the resource. In this case, Microsoft Visual C++ would prompt you to save the resource. If you agree to do t...

How to create a new static library project in Visual C++

From the File menu, select New and then Project…. From the Project types pane, under Visual C++, select Win32. From the Templates pane, select Win32 Console Application. Choose a name for the project, such as MathFuncsLib, and enter it in the Name field. Choose a name for the solution, such as StaticLibrary, and enter it in the Solution Name field. Press OK to start the Win32 application wizard. From the Overview page of the Win32 Application Wizard dialog, press Next. From the Application Settings page of the Win32 Application Wizard, under Application type, select Static library. From the Application Settings page of the Win32 Application Wizard, under Additional options, deselect Pre-compiled header. Press Finish to create the project.

Overview

In an MFC application, a resource is a text file that allows the compiler to manage such objects as pictures, sounds, mouse cursors, dialog boxes, etc. Microsoft Visual C++ makes creating a resource file particularly easy by providing the necessary tools in the same environment used to program. This means you usually do not have to use an external application to create or configure a resource file (as done in other programming environments).