Deriving from Property Extension Template Classes

To reduce implementation effort, it often makes sense to derive your COM wrapper class from the IOPMPropertyExtensionImpl interface. Deriving from this interface provides “boilerplate” implementations of the IOPMPropertyExtension, ICategorizeProperties, and IPerPropertyBrowsing interfaces. IOPMPropertyExtensionImpl uses the information you provide through the OPMPROP_MAP macros to implement these interfaces.

The following OPMPROP_MAP macros are declared in the opmimp.h file:

These macros accept some or all of the following parameters:

nDesID

Description string ID for the property

dpid

The property's DISPID

ctid

Category ID for the property, which is defined in the application's string table resource and used by ICategorizeProperties::MapPropertyToCategory()

ctNameID

Category name string for the property

elementsID

Expanded property name list (semi-colon delimited), which is used by IOPMPropertyExpander::GetElementStrings()

These strings allow a single property to expand into multiple sub-properties. For example, the vertex for a lightweight polyline expands into two values, X and Y. In that case, the expanded property name list would be “Vertex X; Vertex Y”. The number of strings provided for an expandable property should match the number specified in the grp parameter.

predefID

ID of a predefined string list (semi-colon delimited) for the property, which is used by IPerPropertyBrowsing::GetPredefinedStrings()

This list specifies the possible string values for a single property. These strings display in a drop-down list. For example, if the string referenced by this value is “Yes;No”, Yes and No values are displayed in the drop-down list. Users can select onlyone from the list.

vals

Predefined value list (semi-colon delimited) for the property, which is used by IPerPropertyBrowsing::GetPredefinedValues()

These numeric values correspond to each string in the predefined string list. For example, if predefID is “Yes;No” and this value is “1;0”, then “Yes” will have a value of 1 and “No” will have a value of 0. When Yes or No is chosen in the Properties palette, the put_xxx() method of the COM wrapper receives a value of 1 or 0 respectively.

To declare an enum property control, you should set predefID to the ID of a semi-colon delimited list of string symbols, and set vals to a semi-colon delimited list of the values assigned to the corresponding predefID symbols. The following example uses string table resource ID IDS_ENUMSTRINGS, which has been set to the string “One;Two” in the project’s string table:

OPMPROP_ENTRY(IDS_EnumTest, 7, PROPCAT_Test,
    IDS_CAT_NAME_Test, 0, IDS_ENUMSTRINGS,
    _ACRX_T("1;2"), 0, 1, IID_NULL, IID_NULL, "")

When the user edits the Enum Test property, the drop-down list will contain “One” and “Two”, which will set the property to 1 or 2, respectively.

grp

Number of elements in an expanded property name grouping, which is used by IOPMPropertyExpander::GetElementGrouping()

This number should be equal to the number of strings specified in elementsID string list. For example, for 3D points, this value is 3 because there are X, Y, and Z values for a single point. For 2D points, it is 2.

editable

Show-property override, which specifies whether a property is editable or read only

other

CLSID for Other... combo item dialog (not used)

clsid

CLSID for the IPerPropertyBrowsing dialog

Controls the dialog that is displayed when the ellipses button is clicked. Examples of properties using a Properties Page are the hatch pattern name property and the hyperlinks property.

ellipsesTxt

Display string for the IPerPropertyBrowsing dialog

This string appears with the ellipses button for the Properties Page. An example is the “ANSI31” hatch pattern name property when you select a hatch object.

If you need to use the IAcPiCategorizeProperties interface, the template class IAcPiCategorizePropertiesImpl also is provided. This can be used in conjunction with the IOPMPropertyExtensionImpl2 template class, which implements only the IOPMPropertyExtension and IPerPropertyBrowsing interfaces.