Tip Use ClassView to jump to the CContainerItem
member functions that are discussed in this section. Follow along by reading the code in ContainerItem.cpp and comparing the member functions to their descriptions below.
Class CContainerItem
is derived from COleClientItem. From the container application’s perspective, a COleClientItem object represents an embedded item, something it can draw and edit. The life of this object spans the life of the container document, as long as the particular item is embedded in the document. A container application typically creates a COleClientItem object in its implementation of the Insert Object command. Indeed, the implementation of CContainerView::OnInsertObject
provided by AppWizard does create the CContainerItem
object, as explained earlier. The application explicitly deletes a COleClientItem object only in certain cases, such as when the user presses DEL when this item is selected or when the entire containing document is destroyed.
The AppWizard-provided implementation of CContainerItem::OnChange
simply calls OnChange in the base class, COleClientItem, and then, just to be safe, invalidates all views of the document.
The framework calls COleClientItem::OnGetItemPosition during in-place activation when OLE needs to determine the location of the item. The AppWizard-provided implementation arbitrarily sets the rectangle of the item to (10, 10, 210, 210). In the next lesson, you will change this implementation to reflect the actual position and size of the embedded item.
The framework calls COleClientItem::OnChangeItemPosition on behalf of a server to change the position of the in-place window, usually as a result of the server window being resized or the extent of the server window being changed. The AppWizard-provided implementation of the OnChangeItemPosition
function calls the base class COleClientItem::OnChangeItemPosition, which in turn calls COleClientItem::SetItemRects to move or resize the item to the new position or size.