The property container interfaces IPropertyContainer and IODPropertyContainer both provide methods for getting and setting property values. The IPropertyContainer interface provides the GetPropertyValue() and PutPropertyValue() methods to get and set the property values as variants. Since dealing with VARIANTs can be cumbersome, the IODPropertyContainer interface provides a group of GetValue() and SetValue() methods, which are overloaded for several common data types. Either interface is equally valid for accessing property values.
Example 10 uses the IODPropertyContainer interface to disable rotation for a symbol component. Notice that the rotation property is nested in the edit property object and is accessed by combining the base property ID for the edit properties with the property ID for the rotation property.
void CMyController::OnInsertMySymbol() { CODSymbolComponent* pSymbol = new CODSymbolComponent(); pSymbol ->Create(IDR_MYSYMBOL); OnInsertSymbol(pSymbol); pSymbol->SetValue(OD_PROP_EDIT + OD_EDIT_CANROTATE, FALSE); } |
The code segment in Example 11, taken from the CODController class, retrieves the values of two properties using the GetValue() method.
void CODController::DblHit(UINT nFlags, CPoint ptDev, int nButton) { CPoint ptLog = ptDev; VpDPtoLP(&ptLog); CODComponent* pCompHit = GetVp()->ComponentHitTest(ptLog); if (pCompHit != NULL) { int nHorzAlignment; if (pCompHit->GetValue(OD_PROP_HORZ_ALIGNMENT, nHorzAlignment)) { // Component has the horizontal alignment property. Value is // is in the nHorzAlignment variable. } else { // Component doesn't support the horizontal // alignment property. } BOOL bCanScale; if (pCompHit->GetValue(OD_PROP_EDIT + OD_EDIT_CANSCALE, bCanScale)) { // bScale contains a boolean value that indicates if // the component can be scaled. } else { // Component doesn't have any edit properties. } } } |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.