Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a tool,something like Edit Tool in ArcMap,when I double click on mouse,and it selects a feature (polyline for example) and draw a sketch on it too,but if I change zoom,the sketch disapears because I draw sketch on the scrren.I know if I can draw sketch on into selection cache (bitmap) it will stay till selection changes,so it doesn't disapear with changing zoom. here are the steps i pass to draw the sketch with current situation:

  1. I take cache count into cachecount variable using screen display object
  2. I take a handle to device countext for cacheIndex=cachecount-1
  3. start drawing using 2 parameters in steps 1 and 2 4.vdraw polyline using screen display DrayPolyline
  4. FinishDrawing



//Get handle to memory device context

HDC HandleDC;

short cacheCount;


short cacheIdx=cacheCount-1;


return hr;

//Draw feature here



Because ArcMap has at least 3 caches,1st for feature,2nd for annotation and graphics and 3rd for selection,i supposed the last feature index must be for selection cach,if I choose another index less than this,it doesn't even draw any thing.I checked this number and it always returns 2 for cachecount,I think because I don't have any graphics or annotation on map,it returns 2(at least I wish it is a true consumption).

but unfortunately it draws polyline on the screen because drawn polyline disapears at the first refresh of map. Is there something wrong with these procedure? May you tell me how I can draw a sketch on the selected feature just like Edit Tool in ArcMap?

share|improve this question
up vote 3 down vote accepted

Cache indexes are generally determined by calling IActiveView.ScreenCacheID.

However, I believe the Edit tool (and most similar tools) does this differently, and that is to hook to the IActiveViewEvents.AfterDraw event. This will allow you to draw your selection (or sketch or whatever you want) just after the feature selection (or any other) drawing phase finishes.

share|improve this answer
ok,thank you very much petr,let me try after draw event and see is the cache index is right index or not,using ScreenCacheID method. – Reza Feb 4 '11 at 10:00
That was right,it works well now,Thank you very much petr.The key idea is using afterdraw event,and also using screencacheid method takes the right index for selection cache – Reza Feb 4 '11 at 10:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.