Common MFC Classes
CRuntimeClass structure
In the CRuntimeClass structure, the class name , the size of the storage space of the object , the version number of the class , and the member functions such as dynamic Creation object and derivation relation judgment are defined. Each class derived from the CObject class has a CRUNTIMECLASS structure associated with it to complete information about the object or base class at run time.
To use the CRuntimeClass structure, you must use the runtime_class () macro together with other MFC macros that are recognized by the runtime type.
CObject class
MFC's CObject class provides programmers with features such as Object diagnostics, run-time type identification, and serialization.
(1) object Diagnosis : Using the member function AssertValid to check the object validity; The value of the data member of the dump output object using the member function, the diagnostic information is placed in a data stream as text and is used for the Output window information display of the debugger. (only for Applications with debug version)
(2) runtime type recognition : Getruntimeclass Returns an associated pointer to the CRuntimeClass structure based on the class of the object that contains the run information for a class, and the function iskindof is used to test the relationship of the object to the given class.
(3) by combining with CArchive , the CObject class provides serialization functionality for its derived classes. To create a derived class that supports serialization, you must add the Declare_serial macro to the class definition and add implement_serial to the class's implementation file.
CCmdTarget class
Derived directly from the CObject class , all can implement the base class of the message map MFC class. The functions are as follows:
(1) message sending:The MFC application creates a static data structure called a message map for each ccmdtarget derived class that maps the message to the message handler function that corresponds to the object.
(2) set cursor: The program is doing something: beginwaitcursor () changes the cursor to an hourglass shape; operation completed: Endwaitcursor () changes the cursor back to the previous shape; RestoreWaitCursor () is used to restore the cursor to a waiting state.
(3) support Automation:CCmdTarget class support program through the COM interface Interactive operation, automatic translation of COM interface methods. Methods are called Enableautomation (), Fromidispatch (), GetIDispatch (), isresultexpected (), and OnFinalRelease ().
CWinThread class
Derived from CCmdTarget, the main work is to create and process message loops .
CWinApp class
Derived from the CWinThread class, the member function initapplication (), InitInstance (), Run ().
In an MFC application, there is only one CWinApp derived class object that represents the main thread that the program runs on, representing the application itself .
CWnd class
Derived directly from the CCmdTarget class, is the most basic GUI object in MFC. The public variable m_hwnd is used to hold the window handle for the API function call.
CFrameWnd class
Derived from the CWnd class, used primarily for the control of a window. Its object is a frame window that includes a boundary, title bar, menu, Maximize button, minimize button, and an active view .
Its common member functions:
getactivedocument () : Gets a pointer to the current document.
GetActiveView () : Gets a pointer to the current view.
SetActiveView (): Activates a view.
GetTitle () : Gets the caption of the frame window.
Settitle () : Sets the caption of the frame window.
Setmessagetext () : Sets the status bar text.
CDocument class
Derived from CCmdTarget, as the base class for user documents, represents the user storing or opening a file . The main function is to separate the processing of the data from the user's interface and provide an interface for interacting with the view class .
The commonly used member functions are:
onnewdocument () : Create a new document.
onopendocument () : opens a document.
MFC common Classes Detailed introduction