Drawing oddity macOS/2017r3

I’ve got a really odd problem when changing the position of some labels.

In my software it’s possible to adjust the size of the font for different areas. On opening the font size and font name are changed for all affected controls in the parent control. There are labels with fixed text (Labels array) and some text is loaded from a database into a label subclass (DataLabels array). I calculate how I need to move the controls and then do the loop over the controls:

[code]'set data labels + labels
for currentControl as Integer = 0 to UBound(DataLabels)

Labels(currentControl).TextSize = hasFontsize
Labels(currentControl).TextFont = hasFont
DataLabels(currentControl).TextSize = hasFontsize
DataLabels(currentControl).TextFont = hasFont

Labels(currentControl).Top = Labels(currentControl).Top + (currentControl * (newStringHeight - oldStringHeight))
Labels(currentControl).Height = Labels(currentControl).TextSize *2
DataLabels(currentControl).Top = Labels(currentControl).Top
DataLabels(currentControl).Height = Labels(currentControl).Height

Labels(currentControl).Width = Labels(currentControl).Width + (newStringWidth - oldStringWidth)
DataLabels(currentControl).Left = DataLabels(currentControl).Left + (newStringWidth - oldStringWidth)

next[/code]

The Labels and the DataLabels obviously should have the same Top and Height. But they don’t:

I’ve checked and rechecked the code. The formula for the string height and widths hasn’t change and is correct. It doesn’t matter if the app is 32 or 64bit. I don’t understand why the Labels and the DataLabels behave differently.

Now if I change the window size the controls have the correct height:

I’ve tried to force a refresh but no dice. Does anyone have an idea what might cause this problem?

Tried window.refresh ir ivalidate?

Yep, both don’t work - with the whole window, the individual controls and the parent. What is also very strange is that loading a different set of data doesn’t force the correct refresh. Only a change in the window size. I’ve also tried the usual

window.width = window.width + 1 window.width = window.width - 1

But even this didn’t work.

Just a shot in the dark, but would it be possible to trigger the resizing code shortly after the open event? I had a similar problem with declared controls on macOS which I could handle by doing the resize a tad later than the open event. A delay of 0 should be enough.

Danke, Ulrich, das hat das Problem behoben!

It would be good to have a Shown Event for Desktop too, because that’s the moment when the control was instantiated as a child of its parent view, at least under macOS.
Meanwhile, delaying resizing to the first event loop seems to be a good substitute. Thanks for your confirmation!