Introduction to MFC
The Microsoft Foundation Classes are a framework for developing complete applications in C++. MFC provides two primary functions:
An object-oriented wrapper for the native Windows user-interface API
Framework facilities that remove much of the grunge work involved in making a complete, standalone Windows application
The object-oriented wrapping is straightforward. Many Windows API
functions take a “handle” as their first parameter; for
example, the function SendMessage() takes a handle
to a window (an HWND),
DrawText() takes a handle to a device context (an
HDC) and so forth. MFC wraps most of these handles
in objects and thus provides CWnd and
CDC classes, both of which have the relevant
methods.
So, instead of writing your C++ code as:
HWND hwnd = CreateWindow(...); // Create a handle to the window... EnableWindow(hwnd); // and enable it.
You may write code similar to:
CWnd wnd; // Create a window object.
wnd.CreateWindow(...); // Create the Window.
wnd.EnableWindow();// And enable it.There are a large number of objects, including generic window objects, frame windows, MDI child windows, property pages, fonts, dialogs, etc. It’s a large object model, so a good MFC text or the MFC documentation is recommended for anything more than casual use from Python.
The framework aspects of MFC provides some useful utility classes, both for structuring your application and performing many of the mundane tasks a good Windows application should do. The mundane but useful tasks ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access