Using AutoCAD Color and Layer Editing Controls

AutoCAD provides ActiveX editing controls for common entity properties such as color and layer. You can apply these controls to custom properties by adding PROP_DISP_ENTRY2 entries to the per-property display map. You pass the DISPID of the property to be edited as the first parameter, and the control's Windows registry root class name. For the color control, this name is AcPEXCtl.AcPePropertyEditorColor.16. For the layer control, it is AcPEXCtl.AcPePropertyEditorLayer.16.

To use these controls with the AcadToolImpl class, you create specifically named Automation properties. For the color control, you must name the property Color and specify its type as VARIANT. For the layer control, you must create a BSTR property named Layer.

The following listing shows a sample pre-property display map:

BEGIN_PERPROPDISPLAY_MAP2()
PROP_DISP_ENTRY2(5, "AcPEXCtl.AcPePropertyEditorColor.16",
    NULL, NULL, NULL, NULL, 0x000000ff, FALSE, 1, 0)
PROP_DISP_ENTRY2(6, "AcPEXCtl.AcPePropertyEditorLayer.16",
    NULL, NULL, NULL, NULL, 0x000000ff, FALSE, 1, 0)
END_PERPROPDISPLAY_MAP2()

This map provides a color control for the property whose DISPID is 5, and a layer control for the property whose DISPID is 6.

Note: The AcadToolImpl class automates full support for only the color and layer editing controls. You may use AutoCAD's other controls through this map, but you must implement the necessary member variables and property accessor methods to do so.