Extending ArcObjects 

Managing custom feature renderers

This topic is relevant for the following:
Product(s): ArcGIS Desktop: All
Version(s): 9.0, 9.1, 9.2
Language(s): VB6, VC++
Experience level(s): Intermediate to advanced



Custom feature renderers are quite simple to manage, generally just requiring the DLL containing the renderer class to be registered on each client PC.

There are three main methods for applying a custom feature renderer to a layer:

Applying the renderer through the Layer Properties dialog box requires you to implement a custom renderer property page registered to the 'ESRI Renderer Property Pages' component category. This is described previously for the PointDispersalRenderer.

Applying your custom renderer with ArcObjects code is the usual method when you have not implemented a custom renderer property page. The following VBA script creates a point dispersal renderer object (you will need to add a reference in the VBA environment to the custom renderer's DLL), then replaces an existing renderer in a particular layer.

[Visual Basic 6]
' pGeoFeatureLayer is an interface pointer to the IGeoFeatureLayer
' interface on a Feature Layer object.
  
' Create the custom renderer
Dim pMyRenderer as IDispersalRenderer
Set pMyRenderer = New PointDispersalVB.Renderer
' You could set some properties here
  
' Now set the custom renderer into the feature layer
Set pGeoFeatureLayer.Renderer = pMyRenderer
pMxDocument.ActiveView.Refresh
pMxDocument.UpdateContents

A custom renderer without an accompanying property page can be applied programmatically.

The third way of applying a custom renderer to a layer is by writing a feature class extension. Your class extension must implement IFeatureClassExtension and IFeatureClassDraw.

In brief, the GUID of the FeatureClassExtension object is stored as an entry in the geodatabase. When the layer for this feature class draws, it looks to the feature class extension and uses the renderer defined there (IFeatureClassDraw::CustomRenderer), which can be either a custom renderer or one of the standard ESRI renderers. You can also associate a custom renderer property page through IFeatureClassDraw::CustomRendererPropertyPageCLSID. If you want to prevent the users from changing the renderer, return True from IFeatureClassDraw::ExclusiveCustomRenderer.

Custom renderers can be applied by feature class extensions that implement IFeatureClassDraw.

For more information about writing feature class extensions, see the section, 'Customizing the geodatabase'. For an example implementation of setting the default renderer with a class extension, see the 'FeatureClassDraw' sample in the ArcGIS Developer Help.

 


Back to top

See Also Point Dispersal Renderer Example and Custom Feature Renderers.