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.
' pGeoFeatureLayer is an interface pointer to the IGeoFeatureLayer ' interface on a Feature Layer object.' Create the custom rendererDimpMyRenderer as IDispersalRendererSetpMyRenderer =NewPointDispersalVB.Renderer' You could set some properties here' Now set the custom renderer into the feature layerSetpGeoFeatureLayer.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.
See Also Point Dispersal Renderer Example and Custom Feature Renderers.