Drawing the Embedded Objects

The AppWizard-provided implementation of CContainerView::OnDraw simply draws the one embedded object pointed to by m_pSelection. Now that Container supports multiple embedded objects, OnDraw must be reimplemented accordingly.

To support drawing of multiple embedded objects

Again, a CRectTracker object is used to draw the rectangle and possibly resize handles around the embedded object. The CRectTracker object lives only long enough to draw during this particular repaint. Another CRectTracker object was used, as you saw above, to handle a click on one of the resize handles. Yet another CRectTracker object was used to change the shape of the cursor when it was over one of the resize handles. Each of these CRectTracker objects is short lived; that is, they are automatic (local) variables of the respective Windows event handler. They were all initialized with the common code you added earlier to SetupTracker.