Couple of points to note
about the generated code:
(1) Control
Initialization: Initialize
the any control data in the constructor CCircle::Circle().
(2) Control
Creation: The control is
created through a function called "Create". It has the following format:
BOOL Create(void* pParent, UINT nID, RECT rect);
Our "Circle"
control is a "CWnd" derived class, thus its "Create" function calls
the same of the base class
CWnd::Create(DWORD dwStyle, CRect rect, CWnd* pWnd, UINT nID);
After the control is
successfully created, CCirclle::Create(..) calls "CreateControls()" to create
its child controls and "SetProperties()" to set the properties of the control
itself and all of its child controls.
CCircle::Create(..) function
creates the Windows handle whereas CCircle::Circle() merely initializes control data. Thus
any initialization that depends on a valid Windows handle should be made after
CWnd::Create(..) function in CCircle::Create() and not in the constructor.
(3) Drawing: Our "Circle" control is drawn in the
function ::DrawControl(..) function, which is called from ::OnEraseBkgnd(CDC* pDC) message
handler. As you can see, RadVC generates the necessary code for handling WM_ERASEBKGND
Windows message in the control files. You will learn more on how to modify the code in
::DrawControl(..) function later in Part 4: Drawing on the New
Control
(4) Child Controls: RadVC inserts declaration code for its child
controls in the following comment block: (circle.h):
// Controls
//{{AFX_CTRL_DECLR_START
//}}AFX_CTRL_DECLR_END
Controls are created in ::CreateControls()
function in circle.cpp.
(5) Control
Attributes: RadVC inserts
code to declare properties, methods and events in the following comment blocks (circle.h):
//Properties
//{{AFX_CTRL_PROP_DEF_START
//}}AFX_CTRL_PROP_DEF_END
//Events
//{{AFX_CTRL_EVENT_DEF_START
//}}AFX_CTRL_EVENT_DEF_END
//Methods
//{{AFX_CTRL_METHOD_DEF_START
//}}AFX_CTRL_METHOD_DEF_END
Later in the following links, you will learn
more how you can add these attributes :
Part 5: Adding a
Property to the New Control
Part 6: Adding an
Event to the New Control
Part 7: Adding a
Method to the New Control
Next >> Part 4: Drawing on the New Control
- Related Links:
- Control
Development Kit (CDK) Home
|