Canvas DrawOval & DrawRect Broke in Windows after Xojo 2016 & Newer

Does anyone know why Canvas Graphics DrawOval & DrawRect Broke in Windows. It works in Xojo 2015r4 and older Xojo 2016 and Newer it’s broke. Is there a Canvas syntax code change. Instead of drawing a Rect or Oval it reduces the diameter from the Pen width and Height. The Xojo Build it works best for Windows is Xojo2015r3.1 making me only use this Build.

   Canvas.PBuffer.Graphics.PenHeight = 4
   Canvas.PBuffer.Graphics.PenWidth = 4
   Canvas.PBuffer.Graphics.ForeColor = &c00FF00
   Canvas.PBuffer.Graphics.DrawOval(ImgX, iYStr, iW, iH)
   Canvas.PBuffer.Graphics.DrawRectl(ImgX, iYStr, iW, iH)

What is PBuffer? You’re not trying to draw from outside the canvas, are you?

Hi Tim

Sorry I forgot to tell what pBuffer is. Yes I’m drawing from the outside the Canvas. The PBuffer is a Picture Property in the Canvas Class that holds the the backdrop picture and the graphics before it’s drawn from the DrawClassObjects Method in the Canvas Class

Self.Graphics.DrawPicture(PBuffer, X, Y, Width, Height, X, Y, Width, Height)

I learned this is from Eugene Dakin Program the Canvas Control pdf Book.

Hi Jeff,

I am guessing that Canvas might need to be Canvas1 or me in the following code:

[quote=323795:@Jeffrey Cox]Canvas.PBuffer.Graphics.PenHeight = 4
Canvas1.PBuffer.Graphics.PenWidth = 4
Canvas1.PBuffer.Graphics.ForeColor = &c00FF00
Canvas1.PBuffer.Graphics.DrawOval(ImgX, iYStr, iW, iH)
Canvas1.PBuffer.Graphics.DrawRectl(ImgX, iYStr, iW, iH)[/quote]

Below is an example with your code that works in Xojo 2017 r1 which updates the picture outside of the Canvas and manually double-buffers the Canvas.
CanvasOval.xojo_binary_project

This is no longer valid (for several years now). Use the g as Graphics variable that is passed into the Paint event. It might be (wild speculation here) that with the switch of graphics engines on Windows, this code no longer works as well as it once did.

Try

g.DrawPicture(PBuffer, X, Y, Width, Height, X, Y, Width, Height)

You guys are awesome and thanks for your help. I’ll share the results to see if it fixed it. Thanks for the code update Eugene.
I’ll make the update the g as graphic too.

My code I used is closest to your book code examples:
Code 130. Example 7-1: CustomCanvas DrawClassObjects Method
Code 333. Example 10-2: CanvasButton Open Event