Add halo to label

1199
1
01-19-2011 06:42 AM
KevinSurbella
New Contributor
Hello,

I would like to add a white halo to labels using arcobjects.  I think I need to reference the IFormattedTextSymbol interphase, but I'm not sure how to implement this into my current code (see below).  Thank you for your help.

Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
' Get the selected layer
Dim pLayer As IGeoFeatureLayer
Set pLayer = pMap.Layer(0)

Dim pFc As IFeatureClass
Dim strOIDName As String
Set pFc = pLayer.FeatureClass
strOIDName = pFc.OIDFieldName

' Get the selected features from the layer
Dim pFSel As IFeatureSelection
Set pFSel = pLayer
Dim pSelSet As ISelectionSet
Set pSelSet = pFSel.SelectionSet
Dim pFCur As IFeatureCursor
pSelSet.Search Nothing, False, pFCur
' Loop through the selected features and create a label
' expression for the selected features
Dim pFeat As IFeature
Dim strSql As String
Set pFeat = pFCur.NextFeature
  Do While Not pFeat Is Nothing
    If strSql = "" Then
      strSql = strOIDName & " = " & pFeat.OID
    Else
      strSql = strSql & " or " & strOIDName & " = " & pFeat.OID
    End If
    Set pFeat = pFCur.NextFeature
  Loop
Debug.Print strSql
' Get AnnotateLayerPropertiesCollection from layer
Dim pAnnoLayerPropsColl As IAnnotateLayerPropertiesCollection
Set pAnnoLayerPropsColl = pLayer.AnnotationProperties
Dim pAnnoLayerProps As IAnnotateLayerProperties
pAnnoLayerPropsColl.QueryItem 0, pAnnoLayerProps, Nothing, Nothing
pAnnoLayerProps.Class = "LabelSel"
pAnnoLayerProps.WhereClause = strSql
Dim aAnnoVBScriptEngine As IAnnotationExpressionEngine
Set aAnnoVBScriptEngine = New AnnotationVBScriptEngine

  Dim pTextsymbol As ITextSymbol
  Set pTextsymbol = New TextSymbol

  Dim pFont As IFontDisp
  Set pFont = pTextsymbol.font
 
  Dim pFormattedtxtsym As IFormattedTextSymbol
  pFormattedtxtsym.ShadowColor = True
 
  pFont.Bold = True
  pFont.size = 10
  pFont.Weight = 2
  pTextsymbol.font = pFont

  Dim pLELayerProps As ILabelEngineLayerProperties
  Set pLELayerProps = pAnnoLayerProps
  Set pLELayerProps.ExpressionParser = aAnnoVBScriptEngine
 
  pLELayerProps.Expression = "[Longlabel] & vbnewline & [Latlabel] & vbnewline & [Elevlabel] & _    vbnewline  &[Driftlabel]"
 
  Set pLELayerProps.Symbol = pTextsymbol

' Display the lables
pLayer.DisplayAnnotation = True
' Refresh the Data Frame
pDoc.ActiveView.Refresh
0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor
Kevin,

Search help for the Interface IMask there is example code that shows you how to set the Halo.

Duncan
0 Kudos