Notifies the host that the designer has used an item from the toolbox.
HRESULT OnItemPicked ();
Parameters
None.
Return Values
The return value obtained from HRESULT is one of the following:
Return Value | Meaning |
S_OK | Success. |
Other statuses | Failure. |
Comments
A designer calls the site's OnItemPicked method to notify the site that it has used an item from the toolbox. For example, if the user performs a click-and-drag operation to place an item from the toolbox on the visual designer, the designer should notify the host. In response, the host can redraw the toolbox as necessary, for example, reselecting the toolbox selection arrow.
Typically, designers use this method in conjunction with their own IDesignerToolbox::ItemPicked method. The host calls ItemPicked to indicate that the user has picked an item from the toolbox. Then the designer takes the appropriate action and calls the host's OnItemPicked method to allow the host to respond.
For example, when the user picks an ActiveX control from the toolbox, the host calls the designer's ItemPicked method. The designer draws the control, then calls the host's OnItemPicked method so the host can refresh the toolbox.
Example
In the following code fragment, the user has picked a control from the host's toolbox and set its location on the designer. The call to the local routine ToolFromDataObject
parses data in the FORMATETC structure, returning a toolbox item; the local routine ObjTypeFromToolType
converts the toolbox item into an object that the designer can place on its visual interface. The designer inserts the control at the requested location, then calls OnItemPicked so the host can reset its tool pointer and refresh the toolbox.
hr = InsertControl (ObjTypeFromToolType(ToolFromDataObject(pDataObject)),
xDropUnits, yDropUnits);
m_pDesignerToolboxSite->OnItemPicked();
See Also