Lock Properties not working when embedwithin

When a container control is manually added to a webpage and the LockLeft and LockRight properties are set to false, the container stays horizontally centered on the page as the windows is resized – Perfect

However, when the container is added to the window using EmbedWithin (code below), the container does not move as the window is resized.

c.EmbedWithin(self,x,y,w,h) c.LockLeft = False c.Lockright = False

Is this a bug or is there something else I need to do?

Thanks!

The simple answer is that Locks needs to be set before embedding.

The full answer includes that this is not documented. And if you change the properties afterwards it will not only not work but the state in the browser and application may get out of sync. For these issues there is Ticket <https://xojo.com/issue/30234>

The locking properties are technically a design-time thing, so once the control is on a layout, they become read-only.

Thanks all for the suggestions, However…

I just tested again with the lock code before EmbedWithin, and now the container is drawn at the left edge of the page, even though the x property read 244. When the Lock code is removed the containers are drawn in the correct location but of course do not stay centered when the window is resized. Sure seems like a bug to me. Running on MacOS 10.12.4 Xojo 2017 1.1.

dim c As ccRow
dim x,y,w,h,i,offset As integer

c = new ccRow
w = c.Width
h = c.Height
x = self.Width / 2 - (w/2)
y = 120

offset = h + 4

for i = 1 to val(rows.Text)
c = New ccRow
c.LockLeft = False
c.LockRight = False
c.EmbedWithin(self,x,y,w,h)
y = y + offset
next

self.MinHeight = y + 10

It may also be related to this bug report: <https://xojo.com/issue/46463>

in your code above, what are the values of Self.Width and ccRow.width when that code runs?

self.width = 1320
c.width = 596 (immediately after c = New ccRow)
x = 362

[quote=328636:@Bart Davis]self.width = 1320
c.width = 596 (immediately after c = New ccRow)
x = 362[/quote]
Ok. Put together a sample project and file a bug report in feedback do I can look more closely at this.