With code I've scraped together from various posts on this site, I am able to display a simple balloon callout with text in a standard ArcMap session. Is it possible to add anything more than just text, for example some html or even something like a windows form?

I am aware of HTML popups - but I don't think they will work for my situation. Without getting to verbose here, the point locations and associated content I want to display don't reside in any feature class. Instead, I have an event handler wired up in ArcMap listening to an external source that invokes the handler with point location & content.

Any thoughts or suggestions?

IMxDocument mxDoc = (IMxDocument)m_application.Document;
IActiveView activeView = mxDoc.ActiveView as IActiveView;
ITextElement pTextElement;
IElement pElement;
ICallout pCallout;
IFormattedTextSymbol pTextSymbol;
IGraphicsContainer pGraphicsContainer;

IPoint anchorPoint = new Point();
anchorPoint.PutCoords(0, 0);

pTextElement = new TextElementClass();
pElement = pTextElement as IElement;
pTextElement.Text = "HELLO WORLD!!!!!!!!!!!!!!!!";

ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;

int x, y;
displayTransformation.FromMapPoint(anchorPoint, out x, out y);
IPoint messagePoint = displayTransformation.ToMapPoint(x, y - 100);
pElement.Geometry = messagePoint;

pTextSymbol = new ESRI.ArcGIS.Display.TextSymbol();
pCallout = new BalloonCallout();
pTextSymbol.Background = pCallout as ITextBackground;
pCallout.AnchorPoint = anchorPoint;
pTextElement.Symbol = pTextSymbol;

pGraphicsContainer = activeView as IGraphicsContainer;
pGraphicsContainer.AddElement(pElement, 0);
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.