Select to view content in your preferred language

Change Callout Balloon Background color

2606
3
09-13-2011 09:45 AM
JeffreyLaird
Deactivated User
Callout Ballon Change Color
In .Net 2010 VB - I can change the color of the text in my callout balloon, but I can't seem to change the color of the balloon itself. Shadowcolor Doesn't do anything. Any help would be appreciated.

Dim pTextElement As ITextElement = New TextElement
Dim pElement As IElement
Dim pPoint As IPoint = New Point
Dim pCallOut As ICallout = New BalloonCallout
Dim pTextSymbol As IFormattedTextSymbol = New TextSymbol
Dim pGraphicsContainer As IGraphicsContainer = pMxDoc.ActiveView

pPoint = pSelFeat.Shape

pLatLonFormat.IsLatitude = True
pLatLonFormat.GetDMS(pPoint.Y, lDegY, lMinY, lSecY)
pLatLonFormat.IsLatitude = False
pLatLonFormat.GetDMS(pPoint.X, lDegx, lMinx, lSecx)

Dim lngStr As String
Dim latStr As String
lngStr = lDegx & Chr(176) & lMinx & "'" & lSecx & """ " & "W"
latStr = lDegY & Chr(176) & lMinY & "'" & lSecY & """ " & "N"

POI = pSelFeat.Value(pSelFeat.Fields.FindField("POI_NUM"))
WMP = pSelFeat.Value(pSelFeat.Fields.FindField("WMP_TYPE"))

pTextElement.Text = POI & vbCrLf & WMP & vbCrLf & lngStr & vbCrLf & latStr ' add coords"

pTextElement.Symbol.HorizontalAlignment = 0
pTextElement.Symbol.VerticalAlignment = 1

' now reproject so that the placement is in Single Zone
pPoint.Project(pMap.SpatialReference)

' get an offset for the balloon
Dim nPoint As IPoint = New Point
nPoint.SpatialReference = pPoint.SpatialReference
nPoint.X = pPoint.X + 500
nPoint.Y = pPoint.Y + 300

pElement = pTextElement
'pElement.Geometry = pPoint
pElement.Geometry = nPoint
pTextSymbol.Background = pCallOut

pTextSymbol.Size = 8

Dim pColor As ESRI.ArcGIS.Display.IRgbColor = New RgbColor
pColor.Blue = 50
pColor.Green = 240
pColor.Red = 50

'this changes the text color.
pTextSymbol.Color = pColor 'changes the text color OK

'************ this gives me an error ************
'pTextSymbol.Background.TextSymbol.Color = pColor

pCallOut.AnchorPoint = pPoint

pTextElement.Symbol = pTextSymbol

pGraphicsContainer.AddElement(pElement, gcnt)
gcnt = gcnt + 1
pElement.Activate(pMxDoc.ActiveView.ScreenDisplay)

pMxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)
0 Kudos
3 Replies
JeffreyHamblin
Occasional Contributor
You need to create an IFillSymbol (New SimpleFillSymbol) and set its color. Then set IBalloonCallout.Symbol to it.

Edit:
Since IBalloonCallout.Symbol IS an IFillSymbol, you can also just set the color directly:

Dim pBalloonCallOut As IBalloonCallout = pCallout
pBalloonCallOut.Symbol.Color = pColor
0 Kudos
JeffreyLaird
Deactivated User
Jeff,

Works like a charm.  Thanks so much for the help!

Jeff
0 Kudos
SteveCole
Honored Contributor
+1 on the thanks. This just helped me solve an issue that's been nagging me for awhile. I could change the text color in the callout but never the color of the outline. This helped me solve it. Thanks Jeff!
0 Kudos