O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required