AnsweredAssumed Answered

problem using IDisplay.DrawPolygon & screen refresh

Question asked by geonetadmin on Jul 7, 2011
Latest reply on Jul 28, 2011 by geonetadmin
Original User: Scole

I ported over a "zoom to parcel" tool from VBA to VB.NET and, in the process I wanted to change part of its functionality. Originally, my script added a graphic polygon element to the display to let the user know which parcel was the one they were interested in.

I wanted to modify this so that the parcel highlight was only drawn to the screen temporarily instead of added as a graphic element. I re-wrote this section of my code to use IDisplay.DrawPolygon but when the code is actually run, the events seem out of sequence. Here's the relevent code:

pEnvelope = pGeometry.Envelope
pEnvelope.Expand(1.5, 1.5, True)

pActiveView.Extent = pEnvelope

pScreenDisplay = pActiveView.ScreenDisplay
pScreenDisplay.StartDrawing(pScreenDisplay.hDC, CShort(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache))

So, from the user experience side, here's the order of events as I witness them:

  1. display zooms to the extent of the parcel

  2. the parcel outline draws (the DrawPolygon step)

  3. the actual parcel features draw

It all happens very fast but the drawing of the data features wipes out my DrawPolygon highlight. How do I get the order of events to behave the way I have coded them??

I tried throwing a System.Threading.Thread.Sleep() statement into the mix but it doesn't correct the issue; it literally just delays it.