![]() |
This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Display > ESRI.ArcGIS.Display > Interfaces > ID > IDisplay Interface > IDisplay.StartDrawing Method (ArcObjects .NET 10.4 SDK) |
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 _ )
[C#] public void StartDrawing ( int hDC, short cacheID );
[C++]
HRESULT StartDrawing(
long hDC,
short cacheID
);
[C++]
Parameters hDC [in] hDC is a parameter of type long cacheID [in] cacheID is a parameter of type short
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.
IDisplay Interface | IDisplay.FinishDrawing Method