0

I'm experimenting with the idea of replacing my dynamic display moving graphics with the static (DynamicDisplayEnabled = false) moving graphics.

public class CustomLayer : BaseCustomLayer
{
        public override void Draw(esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
        {
            int hdc = Display.hDC;
            IntPtr p = new IntPtr(hdc);
            Graphics graphics = Graphics.FromHdc(p);
            Image newImage = Image.FromFile(carImage);
            System.Drawing.Point ulCorner = new System.Drawing.Point(x, y);
            graphics.DrawImage(newImage, ulCorner);
        }
}

This code draws the image, but it only invokes draw once, unless I move the map with the pan tool or change the scale. How can I make the Draw function fire multiple times a second?

1
  • Not an answer but just something you might want to try if the screen just isn't updating as you expect: call IScreenDisplay.UpdateWindow to force the window to respond to any pending WM_PAINT messages. Things weren't drawing in the expected order for me without a call to that after IActiveView.Refresh but before my StartDrawing/EndDrawing section.
    – blah238
    Commented Jul 12, 2011 at 3:33

1 Answer 1

1

It's been a while, but when I was working on a project for vehicle tracking I think we used a timer in conjunction with Dispatcher.CurrentDispatcher to force a refresh. See this answer on using CurrentDispatcher.

I think we checked to make sure IViewRefresh.Drawing was false before calling refresh, but I think there were issues with that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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