MFC Library Reference
Enables objects of CObject-derived classes to be created dynamically at run time when used with the DECLARE_DYNCREATE macro.
The framework uses this ability to create new objects dynamically, for example, when it reads an object from disk during serialization. Add the IMPLEMENT_DYNCREATE macro in the class implementation file. For more information, see CObject Class Topics.
If you use the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros, you can then use the RUNTIME_CLASS macro and the CObject::IsKindOf member function to determine the class of your objects at run time.
If DECLARE_DYNCREATE is included in the class declaration, then IMPLEMENT_DYNCREATE must be included in the class implementation.
Note that this macro definition will invoke the default constructor for your class. If a non-trivial constructor is explicitly implemented by the class, it must also explicitly implement the default constructor as well. The default constructor can be added to the class's private or protected member sections to prevent it from being called from outside the class implementation.
Header File: afxmt.h
BEGIN_MESSAGE_MAP( theClass, baseClass ) Parameters theClass Specifies the name of the class whose message map this is. baseClass Specifies the name of the base class of theClass. Remarks Use the BEGIN_MESSAGE_MAP macro to begin the definition of your message map. In the implementation (.CPP) file that defines the member functions for your class, start the message map with the BEGIN_MESSAGE_MAP macro, then add macro entries for each of your message-handler functions, and complete the message map with the END_MESSAGE_MAP macro. Example // example for BEGIN_MESSAGE_MAP BEGIN_MESSAGE_MAP( CMyWindow, CFrameWnd ) //{{AFX_MSG_MAP( CMyWindow ) ON_WM_PAINT() //该消息映射宏主要是将OnPaint()函数与应用程序框架联系在一起。 ON_COMMAND( IDM_ABOUT, OnAbout ) //}}AFX_MSG_MAP END_MESSAGE_MAP( ) |