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

Links

Official resources MSDN Visual C++ Home microsoft.public.vc.language The Top CodeGuru CodeProject DeveloperFusion.com C/C++ Users Journal RSDN (RU) First Steps (RU) Sources.ru (RU) Tricks, Tips, FAQs Bjarne Stroustrup's C++ Style and Technique FAQ CodeGuru FAQ C++ FAQ Lite by Marshall Cline CodeProject Forum FAQ Boob Moore's page (Win32, NT, MFC) Edelmiro Fuentes's page http://www.sources.ru/cpp/cpp_vcpp_faq.shtml (RU) Akzhan Site (RU) Forums, newsgroups CodeGuru Forum microsoft.public.vc.language comp.lang.c++ RSDN Forum (RU) Libraries, Components, Add-ons, Add-ins Boost Libraries #1 for C++! TinyXML - light yet powerful XML library. Forget about MSXML! :) Whole Tomato Software: Code syntax highlighting Compuware corporation: BoundsChecker, SoftICE etc. Xtreme ToolkitPro - Industry leading Visual C++ MFC UI controls. STL Error Decryptor UCanCode: XD++ MFC Class Library for Diagrams Regular Expression Library Disk File Sy...

Introduction to Microsoft Visual C++/MFC

Microsoft Visual C++ is a programming environment used to create applications for the Microsoft Windows family of operating systems. To use these lessons, you must have installed either Microsoft Visual Studio 2010. Although Microsoft Visual Studio 2010 Professional provides many programming environments for the price of one, in our lessons, we will use it but we will cover only the Microsoft Foundation Class (MFC) library side. After installing it, to use the programming environment, you must first open it. To do that, you would click Start -> (All) Programs -> Microsoft Visual Studio 2010 -> Microsoft Visual Studio 2010. In our lessons, unless used in code, the -> arrow means an action that should follow another. Based on this: Edit -> Copy means click Edit, then click Copy View -> Toolbars -> Custom means click View position the mouse on Toolbars, and then click Custom To start Microsoft Visual C++ or Visual Studio, on the Taskbar, click Start (All) Prog...

A Window's Instance

When you start an application such as Notepad, you are said to have created an instance of the application. In the same way, when you declare a variable of a class, an instance of the class is created and made available to the project. The WinMain() function also allows you to create an instance of an application, referred to as the hInstance argument of the WinMain() function. The instance is created as an HINSTANCE . The CWinApp class provides a corresponding instance variable called m_hInstance . This variable can let you get a handle to the instance of your application. Alternatively, to get a handle to the instance of your application, you can call the AfxGetInstanceHandle() global function. Its syntax is: HINSTANCE AfxGetInstanceHandle(); Even more, to get a handle to your application, you can call the Win32 API's GetWindowLong() function. Suppose you have opened Notepad to view the source code of an HTML document. This is said that you have an instance of Notepad. Imag...