Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.draw polyline using screen display DrayPolyline

5.FinishDrawing

.............................................

HRESULT hr;

//Get handle to memory device context

HDC HandleDC;

short cacheCount;

this->m_ipSDisp->get_CacheCount(&cacheCount);

short cacheIdx=cacheCount-1;

this->m_ipSDisp->get_CacheMemDC(cacheIdx,(OLE_HANDLE*)&HandleDC);

if(FAILED(hr=this->m_ipSDisp->StartDrawing((OLE_HANDLE)HandleDC,cacheIdx)))
return hr;

//Draw feature here


this->m_ipSDisp->FinishDrawing();

.............................................

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?

Regards

share|improve this question
add comment

1 Answer

up vote 1 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
add comment

Your Answer

 
discard

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.