Win32 vs. MFC

Software Development Kit (SDK)

It is a set of tools designed to help C programmers create Windows applications.

Windows SDK consists of the large set of books describing functions, messages, structures, macros and resources .There are also tools including a dialog editor and an image editor, on-line help files and a set of windows libraries and header files. It has large collection of API functions written in C.

What is an API?

API is an acronym for Application Programming Interface.It is simply a set of functions that are part of Windows OS. Programs can be created by calling the functions present in the API.The programmer doesn’t have to bother about the internal working of the functions .By just knowing function prototype and return value he can invoke the API functions. A good understanding of Windows API would help you to become a good Windows programmer .Windows itself uses the API to perform its GUI magic.
Windows APIs are of two basic varieties:
API for 16-bit Windows (Win16 API)
API for 32-bit Windows (Win32 API)
Each of these have sub-APIs within it. If you are working in Windows 3.1 then you have to use Win16 API and in Windows NT you have to use Win32 API.

Microsoft Foundation Class (MFC)

VC++ provides us a rich class library called the MFC Library, which is a set of C++ classes that encapsulate the functionality of applications written for the Microsoft Windows Operating System. The class library gives you a complete application framework .The framework defines an architecture for integrating user interface of an application for Windows with the rest of the application. It also provides implementations for a set of the user-interface components.MFC represents entire family of class libraries.MFC offers high level of abstraction that lets you focus in details to your application while allowing its classes to be customized and extended.MFC makes programming in Windows and C++ a much more productive endeavour.It is a collection of Windows API calls which are written in C.Programming in MFC reduces the code to a considerable extent as compared to SDK.

Let ‘s look at the program that creates simple window using MFC.

Code: CPP

#include <afxwin.h>//The CWinApp class is the base class from which you derive //a Windows application object.//An application object provides member functions for initializing your application//(and each instance of it) and for running the application

// Override InitInstance to initialize each new instance of your application running //under Windows.Typically ,you override InitInstance to construct your main window //object and set the CWinThread : : m_pMainWnd data member to point to that //window.

Comparing MFC vs SDK program

Thus we can see that programming in MFC reduces the code to a considerable extent as compared to SDK.

This is because in SDK we have to write the whole code right from scratch,i.e,we need to write each and every function.Whereas in case of an MFC program the MFC does lot of things on behalf of the user, i.e we need not write each and every function explicitly.