This document is archived and information here might be outdated.  Recommended version.


How to draw points (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Appendix: ArcObjects in Visual C++ > Samples > Cartography > Display > How to draw points

How to draw points


Use this subroutine to draw a Point feature on the screen. With this example the point will not persist on the screen; it will disappear when the screen next refreshes. See the Buffer Polygons sample for an example showing how drawings can be persisted on the display.

How to use

  1. Stub out the code to implement a tool.
  2. Paste the code below into its OnMouseDown event.
  3. Add the tool to an ArcMap toolbar, select it, and click somewhere on the focus map.
[VCPP]
STDMETHODIMP CToolControl1::OnMouseDown(LONG button, LONG shift, LONG x, LONG y)
{
  IDocumentPtr ipDoc;
  m_ipApp->get_Document(&ipDoc);
  IMxDocumentPtr ipMxDoc(ipDoc);
  IMapPtr ipMap;
  ipMxDoc->get_FocusMap(&ipMap);
  IActiveViewPtr ipActiveView(ipMap);

  IScreenDisplayPtr ipScreenDisplay;
  ipActiveView->get_ScreenDisplay(&ipScreenDisplay);

  ISimpleMarkerSymbolPtr ipMakerSymbol(CLSID_SimpleMarkerSymbol);
  ISymbolPtr ipSym(ipMakerSymbol);

  OLE_HANDLE hDC;
  ipScreenDisplay->get_hDC(&hDC);
  IPointPtr ipPoint;
  ipMxDoc->get_CurrentLocation(&ipPoint);

  ipScreenDisplay->StartDrawing(hDC, esriNoScreenCache);
  ipScreenDisplay->SetSymbol(ipSym);
  ipScreenDisplay->DrawPoint(ipPoint);
  ipScreenDisplay->FinishDrawing();

  return S_OK;
}






Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced