<< Return to Main Index

< Return to Class Index

CGXControl::OnInitChildren

virtual void OnInitChildren(ROWCOL nRow, ROWCOL nCol, const CRect& rect);

nRow

Specifies the row id.

nCol

Specifies the column id.

rect

Specifies the cell rectangle.

Remarks

This method is called prior to drawing the cell.  It computes the rectangles for the CGXChild objects.

If you have CGXChild objects included in your control, you should override this method. The child rectangles should not intersect the interior rectangle you compute with GetCellRect.

In the CGXSpinEdit control, the interior rectangle is used for displaying the text (or number). This rectangle is computed in GetCellRect from the cell rectangle by subtracting the area needed for the spin buttons. OnInitChild sets the rectangle for the arrow buttons.

The rectangle for a child is set by calling its SetRect method (see example).

Example

CGXSpinEdit has two children. Pointers to the children are stored in m_pUpArrow and m_pDownArrow.

void CGXSpinEdit::OnInitChildren(ROWCOL nRow, ROWCOL nCol, const CRect& rect)
{
   nRow, nCol;

   const int nEditBtnWidth = 13;

   // init arrow buttons
   CRect rectBtn;
   rectBtn.IntersectRect(rect,
         CRect(rect.right-2-nEditBtnWidth,
            rect.top+1, rect.right-2, rect.bottom-2)
      );

   m_pUpArrow->SetRect(
         CRect(rectBtn.left, rectBtn.top,
            rectBtn.right, rectBtn.top+rectBtn.Height()/2)
      );
   m_pDownArrow->SetRect(
         CRect(rectBtn.left, rectBtn.top+rectBtn.Height()/2,
            rectBtn.right, rectBtn.bottom)
      );
}

See Also

CGXControl::GetCellRect CGXChild::SetRect

CGXControl

Class Overview | Class Members