EmbedWithin Get Top to be Relative to Container

I have a subclassed canvas with a method called AddContainer that adds a container with:

theContainer.embedwithin( self, left, top )

Why is top always relative to the window and not the canvas?

Thank you

[quote=229002:@Mark Scardingo]I have a subclassed canvas with a method called AddContainer that adds a container with:

theContainer.embedwithin( self, left, top )

Why is top always relative to the window and not the canvas?[/quote]

You are embedding within self. That is the window.

But I tried Me and I get the same result.

You cannot embedwithin a canvas.
http://documentation.xojo.com/index.php/ContainerControl.EmbedWithin

Just add the canvas left and top to the embedding coordinates.

Thanks, Michel. For some reason I started to think Canvas was a RectControl.

It is. But fact remains you cannot embedWithin it.

Of course you can: ContainerControl.EmbedWithin

[quote]ContainerControl.EmbedWithin ( ContainingWindow as Window, [left as Integer], [top as Integer], [width as Integer], … )

ContainerControl.EmbedWithin ( Container as RectControl, [left as Integer], [top as Integer], [width as Integer], … )[/quote]
Mark was correct when he tried it and then wrote – Canvas is a RectControl:[quote=229095:@Mark Scardingo]For some reason I started to think Canvas was a RectControl.[/quote]

So you can do this:

Sub Open() // we are in the open event of a canvas Dim c As New ContainerControl1() c.EmbedWithin(Me, 0, 0, Me.Width, Me.Height) // Me is the canvas, the CC will be positioned relative to the canvas, meaning on the top left // of the canvas, not the window End

You can actually embed a container within any control, even buttons, scrollbars and progress wheels…

I don’t understand what you mean. You can embed a container control in any kind of RectControl:

You are right. Sorry.