Вы находитесь на странице: 1из 1

Introduction to MFC

The Microsoft Foundation Class Library (MFC Library) is a C++ class library released with
Microsoft Visual C++ to support application development on Microsoft Windows. Although
MFC is most often used in GUI applications, it can be used to develop any type
of application. The MFC Library consists of numerous classes that are thin wrappers for high
level Application Programming Interfaces (APIs). The MFC library can either be linked
statically or dynamically into your application. If it is linked dynamically, then
your application is very small. At runtime, your application uses MFC classes through the MFC
dynamic link libraries. Also, if the library is already loaded when one application is running,
then the next application that uses MFC dynamically loads faster.

All the MFC Classes have a capital C prefix. For instance, CString, CFile, CSocket are classes
found in the MFC library. The standard MFC classes are declared in the header file afxwin.h. If
you do not use the App Wizard, you will have to turn on the MFC by modifying the project
settings in Visual C++ to either static or dynamic MFC linking.

CStringClass
The CString class is a member of the MFC library. The class offers an easy to manipulate
strings without resorting to using the C string library. The CString class has several overloaded
operators to access and modify strings. CString instances can either hold standard C strings or
unicode strings. A CString object can be used any where a const char * or a const wchar_t *
types.

Data structure
For handling aggregates of data, the class library provides a group of collection classes arrays,
lists, and maps that can hold a variety of object and predefined types. You can readily derive
specialized collection classes from these, or you can create them based on the template classes.
Arrays are one-dimensional data structures that are stored contiguously in memory. They support
very fast random access since the memory address of any given element can be calculated by
multiplying the index of the element by the size of an element and adding the result to the base
address of the array. But arrays are very expensive if you have to insert elements into the array,
since the entire array past the element inserted has to be moved to make room for the element to
be inserted. Arrays can grow and shrink as necessary.
Lists are similar to arrays but are stored very differently. Each element in a list also includes a
pointer to the previous and next elements, making it a doubly linked list. It is very fast to add or
delete items because doing so only involves changing a few pointers. However, searching a list
can be expensive since all searches need to start at one of the list's ends.
Maps relate a key value to a data value. For instance, the key of a map could be a string and the
data a pointer into a list. You would ask the map to give you the pointer associated with a
particular string. Map lookups are fast because maps use hash tables for key lookups. Adding
and deleting items is also fast. Maps are often used with other data structures as auxiliary indices.
MFC uses a special kind of map called a message map to map Windows messages to a pointer to
the handler function for that message.

Вам также может понравиться