Skip to content

Updating Code That Used The Graphics Property

Prior to Xojo 2018r3 Window and Canvas both had a Graphics property that you could access and draw to. This was deprecated in 2011 because it had significant performance issues on all platforms. The preferred way to draw your graphics since 2011 has been to use the Window.Paint or Canvas.Paint event handlers and the supplied parameter g As Graphics.

Starting with Xojo 2018r3, this Graphics property was removed from Window and Canvas so if you had code that was still relying on it, that code will no longer compile. Here are some tips on how you can migrate your code to use the Paint event handlers and tell the Canvas to update with a call to Invalidate.

If your code was simple and just drawing a Picture to the Graphics property, then you would just move the code to the Paint event handler. For example, this code is drawing a picture:

Canvas1.Graphics.DrawPicture(MyPic, 0, 0)

Where that code existed, you would tell it to redraw Canvas1:


And then in the Canvas.Paint event handler you would draw the picture:

g.DrawPicture(MyPic, 0, 0)

For more information and other strategies to handle more advanced situations, refer to the topic in the documentation: Updating Code That Used the Graphics Property