Canvas paint problem in 2017r1.1

I am painting some text into a canvas using the Canvas.Paint event with this code:

'Calculate Size of text string based on text in Label9
Dim strShape as New StringShape
strShape.TextFont = Label9.TextFont
strShape.Bold = Label9.Bold
strShape.Italic = Label9.Italic
strShape.TextSize = Label9.TextSize
strShape.Text = Label9.Text

Dim p as new Picture(1, 1, 32)
p.Graphics.TextFont = strShape.TextFont
p.Graphics.TextSize = strShape.TextSize
p.Graphics.TextUnit = strShape.TextUnit

Dim Wid as integer = p.Graphics.StringWidth(strShape.Text)
Dim Ht as integer = p.Graphics.StringHeight(strShape.Text, 500)

'Paint text string positioning with Wid/Ht
g.ForeColor = Label9.TextColor
g.TextFont = Label9.TextFont
g.Bold = Label9.Bold
g.Italic = Label9.Italic
g.TextSize = Label9.TextSize

g.DrawString(Label9.Text, (me.Width - Wid)/2, (me.Height - Ht)/2+(Ht/1.5))

This works fine in 2016r3 on both Mac and Windows but does not work in Windows from 2017r1.

Is this a known problem or am I doing something wrong here?

thanks

What does it mean “but does not work in Windows from 2017r1”?

Have you tried to Invalidate the Canvas (or the affected Part of the Canvas) at the end of your Paint Code?

trying to figure out what all that StringShape code is adding to the situation?

'Paint text string positioning with Wid/Ht

g.ForeColor = Label9.TextColor
g.TextFont = Label9.TextFont
g.Bold = Label9.Bold
g.Italic = Label9.Italic
g.TextSize = Label9.TextSize
Dim Wid as integer = g.StringWidth(strShape.Text)
Dim Ht as integer = g.StringHeight(strShape.Text, 500)
g.DrawString(Label9.Text, (me.Width - Wid)/2, (me.Height - Ht)/2+(Ht/1.5))

[quote=343285:@Sascha S]What does it mean “but does not work in Windows from 2017r1”?

Have you tried to Invalidate the Canvas (or the affected Part of the Canvas) at the end of your Paint Code?[/quote]

Opening and running the project in Xojo 2016r3 for Windows does not show the problem, only Xojo 2017r1.1 for Windows gives this problem. I have used Invalidate(true) and Invalidate(false) but it does not change the outcome.

This is making a temporary picture out of the text I want to display in the canvas. The text comes from a Label control brought in from an external file. I work out the width and height of the text with the StringShape so that I can place it accurately in the canvas control.

Why waste all that overhead… when the destination graphic object can do all that for you (see my example)

and you didn’t answer Sascha question…[quote=343292:@Malcolm Wooden]@Sascha S What does it mean “but does not work in Windows from 2017r1”?[/quote]
no output? garbled output? what?

Do you have a link for that Dave?

no output

[quote=343295:@Malcolm Wooden]Do you have a link for that Dave?

no output[/quote]
Link for what? read my post above… that is what I was referring to