CapitolSoft Banner

To add a property to your RAD C++ control, you need to invoke the dialog by clicking the right mouse button on the control bitmap on the RadVC toolbox and then selecting "Add Property" context menu item:

CppCtrl_AttribMenu.jpg (30035 bytes)

The "Add Property" dialog box will now appear.

CppCtrl_PropDlg.jpg (20448 bytes)

For our "Circle" control, we will add a property called "CircleShape". "CircleShape" is a Boolean type of property that defines the circular shape of the control. When this property is set as "TRUE", the circle is drawn as a perfect circle. The circle will be drawn within the bounding rectangle of the control. To determine how to draw the circle, you simply calculate he square region centered within the bounding rectangle of the control. When the "CircleShape" property is set to FALSE, an ellipse is drawn.


When Clicked on the "OK" button in "Add Property" dialog, RadVC opens the control implementation file (circle.cpp) and highlighting the "GetCircleShape" function..

BOOL CCircle::GetCircleShape()
    return m_CircleShape;

void CCircle::SetCircleShape(BOOL bCircleShape)
    m_CircleShape = bCircleShape;
void CCircle::DrawControl(CDC* pDC, CRect rect)
               int nWidth = rect.Width();
               int nHeight = rect.Height();
               if(nWidth > nHeight)
                     rect.left = (nWidth - nHeight) / 2;
           rect.right = rect.left + nHeight;
     else if(nHeight > nWidth)
            = (nHeight - nWidth) / 2;
           rect.bottom = + nWidth;
        pDC->FillSolidRect(rect, RGB(192, 192, 192));
        pDC->DrawText(_T("C++ Rules!!"), rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);



Next >> Part 6: Adding an Event to the Control

Related Links:
Control Development Kit (CDK) Home



Microsoft Visual C++, Microsoft Visual Basic and Microsoft Visual Studio are registered trademarks of Microsoft Corporation.
Copyright 1998-2000 Capitolsoft Corporation. All rights reserved.
Disclaimer: Capitolsoft Corporation is an independent business organization incorporated with the State Commission of Virginia and hence has no connection with U.S. Capitol or any other federal agency of U.S. government. Opinions expressed by the individuals in this site are of their own alone and hence do not necessarily reflect the views of Capitolsoft Corporation.


This page was last updated on November 21, 2005
Hit Counter