Creating custom elements


Summary At times you may want to create a custom graphic element; for example, if you want to combine graphics and text, or draw a geometry that is unsupported (such as a triangle). This document outlines how to create your custom element.

In this topic


Creating a subtype of element

You can see from the following object model diagram (OMD) that the element coclasses are subtypes of the Element abstract class. Therefore, any custom element should implement a minimum of IElement, IElementProperties, IBoundsProperties, and ITransform2D. The IElementProperties2 interface can also be implemented for completeness, although this is not essential for an element to function.
In addition, elements should always implement IClone and either IPersist and IPersistStream or IPersistVariant depending on your development environment. You may also want to implement IPropertySupport, as this will increase compatibility with existing graphics tools. However, it is not mandatory and cannot be implemented in Visual Basic (VB).
Elements can be cloned and persisted and are stored in the document.

FrameElement or GraphicElement

In the following OMD, elements are split farther, with coclasses inheriting from the GraphicElement or FrameElement abstract classes. Your next design decision should be whether your custom element is a FrameElement or GraphicElement. See the following illustration:
  • A FrameElement implements IFrameElement and forms a border around other elements or objects. Many FrameElements, such as MapFrame and TableFrame, only appear on a page layout.
  • A GraphicElement draws simple graphic shapes, pictures, or text; for example, the MarkerElement, LineElement, and TextElement. The IGraphicElement interface adds the ability for an element to appear on page layout or in data view.
Some elements, such as GroupElement and BMPPictureElement, implement both IFrameElement and IGraphicElement. They can appear as simple graphics that are drawn with a surrounding frame and placed on a page layout or in data view.
ArcGIS uses different kinds of elements. Some elements only appear in page layout view. GraphicElements can be added to a map and account for changes in the map's coordinate system. FrameElements have a surrounding neatline.

General design issues for a custom element

The following is a brief review of some design decisions you may need to make when creating a custom element:
  • Does the element need to appear in the data view? If so, create a subtype of GraphicElement. Does the element need a neatline to surround it? If so, create a subtype of FrameElement.
  • Do you need access to the current map for the element to draw or behave correctly? If so, you should consider using VC++ and creating a subtype of MapSurround instead.
  • If you decide your graphic element needs access to the current document (like this example), make sure your element can degrade its behavior safely if instantiated in a process outside ArcMap; for example, the MapControl or PageLayoutControl.
  • When deciding which existing element interfaces to implement in addition to the functionality you want to add, consider which existing property pages apply to your element.


See Also:

Creating different kinds of custom elements




Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime