ArcObjects Library Reference (Display)  

IDisplay.StartDrawing Method

Prepare the display for drawing. Specify the device context and the cache to draw to (normally esriNoScreenCache). The ScreenDisplay coclass will automatically create a window device context if you specify hdc = 0.

[Visual Basic .NET]
Public Sub StartDrawing ( _
    ByVal hDC As Integer, _
    ByVal cacheID As Short _
public void StartDrawing (
    int hDC,
    short cacheID
HRESULT StartDrawing(
  long hDC,
  short cacheID


hDC [in]   hDC is a parameter of type long cacheID [in]   cacheID is a parameter of type short

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


StartDrawing and FinishDrawing are used to manage clipping, symbols, and caching. Call StartDrawing and FinishDrawing anytime you want to draw to a device such as a display, printer, or cache (bitmap).  However, if you are drawing in response to IActiveViewEvents::AfterDraw, the Map object automatically makes these calls for you.

StartDrawing has two parameters: hDc and cacheID.  The hDc parameter specifies the target device where drawing will occur, usually a display, printer, or bitmap.  The cacheID parameter activates a specific cache. In most cases, esriNoScreenCache should be used. 

Specifying a cache sets it as the screen's active cache.  When esriNoScreenCache is used, it sets the display's active cache to zero and drawing occurs directly in the device. Specify a cache when you don't want to draw to a screen directly and you instead want to draw to a cache (bitmap) that may ultimately be copied to the screen.  For example, when ArcMap draws geography, it draws it to a specific cache and then the cache is copied to the screen.  When the screen repaints, instead of drawing all the data from scratch again, the software checks if the cache is dirty or not and simply redraws the bitmap to save time if it can.  When drawing to a cache, the hDc parameter should be the device context of the bitmap, use the IScreenDisplay::CacheMemDC property to get a particular cache's hDC.

Each time you need to change the cache you are drawing to, you must do so inside a new StartDrawing / FinishDrawing block.  For example,  ArcMap usually creates three caches: one for geography layers, one for graphics and annotation, and one for selections.  ArcMap draws each of these phases within a separate StartDrawing / FinishDrawing block.

There are times when may need to draw shapes directly to screen without having them become part of a display cache.  For example, drawing moving objects.   In these cases, use IScreenDisplay::WindowDC to get the device context of the display and esriNoScreenCache as the cacheID.

If a zero is specified for the hDc parameter, the Windows API function GetDC is used to populate IScreenDisplay::WindowDC with the hDC of the main display and drawing is sent here.

As mentioned above, if you drawing in response to the IActiveView::AfterDraw event, the Map object calls StartDrawing and StopDrawing for you.  Also, if the draw phase you are drawing after is cached, your drawings will be cached as well.
StartDrawing fires the IDisplayEvents::DisplayStarted event.

See Also

IDisplay Interface | IDisplay.FinishDrawing Method

.NET Snippets

Flash Geometry

.NET Related Topics

Display events