RTTI and DYNAMIC
DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC are used in conjunction to give runtime type identification ability to a class object.
DECLARE_DYNAMICThis macro adds the ability to access run-time information about an object's class when deriving a class from CObject.
Syntax: DECLARE_DYNAMIC(class_name )Add the DECLARE_DYNAMIC macro to the header (.h) module for the class, then include that module in all .cpp modules that need access to objects of this class. If DECLARE_DYNAMIC is included in the class declaration, then IMPLEMENT_DYNAMIC must be included in the class implementation.
IMPLEMENT_DYNAMICGenerates the C++ code necessary for a dynamic CObject-derived class with run-time access to the class name and position within the hierarchy.
Syntax: IMPLEMENT_DYNAMIC(class_name, base_class_name )Remarks Use the IMPLEMENT_DYNAMIC macro in a .cpp module, and then link the resulting object code only once.
RUNTIME_CLASS macro and the CObject::IsKindOf function is used to determine the parent class name of an objects at run time. For example we have a drawing application and this uses an abstruct class interface called CDrawObj to draw any shape. We have given user to add custom shapes through library. This is to extend the drawing facility. User should derive a custom class from CDrawObj and should define Draw() function. User can pass any object pointer of any type and application might crash while calling Draw() directly. Thus application should validate the object if it is derived from CDrawObj and then it should invoke Draw(). In this application we are checking user provided object if these are kind of CDrawObj.
CRectangle is IsKindOf CDrawObj 1 CRectangle is IsKindOf CObject 1 CRectangle is IsKindOf CDrawObj 1 CRectangle is IsKindOf CObject 1
About our authors: Team EQA
MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.
This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...
Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.
DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.
LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.
We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks