WebContainer width and height are zero!?

In my application I instantiate my WebContainers at run time.

    Session.myControl = new myControl
    
    dim w as integer = Session.myControl.Width
    dim h as integer = Session.myControl.Height

    Session.myControl.EmbedWithin(self, 0, 0, w, h)
    Session.myControl.ShowCenteredInParent(self) // Sets left top of control so centered in parent window.
    [/code]
[code]Sub ShowCenteredInParent(parent as WebPage)
  Left = (parent.width - Width) / 2
  top = (parent.height - Height) / 2
  
  if left < 0 then left = 0
  if top < 0 then top = 0
  if left > parent.width then left = 0
  if top > parent.height then top = 0
  
  if Width = 0 then
    System.DebugLog("Wait a second. w=" + str(Width) + " h=" + str(Height))
    end if
  
  Visible = true
  
End Sub

Since migrating to Xojo from RS this control just stopped appearing when it should… or use to.
However no other control has show this behavior. (All my other controls appear as normal)

The debug log, shows that Width and Height are 0.
I looked in the IDE and the width and height are 477, 875…
I’m confused. Maybe there are some properties that aren’t set unless the control has been open?

When does this code run? Before or after the Shown event?

This code is run before the Shown event I assume. (As do all the other controls)
Pardon the newbie question about Xojo but in RB I saw a list of all the events that a control could receive, in Xojo one only sees what one implements. So how do I add a handler events?

Click the “+” button on the command toolbar and select “Event Handler”.

You might want to also review the Upgrade Guide, which points out differences like this (Help->Upgrade Guide).

Thanks for the tips.

dim ctrl as new ConfigurationContainerControl dim w as integer = ctrl.Width dim h as integer = ctrl.Height ctrl.EmbedWithin(self, 0, 0, w, h) ctrl.ShowCenteredInParent(self)

The Embed with documentation leads me to believe that the shown event is not relevant. Why just this control?

[quote]Dim login As New LoginContainer
login.EmbedWithin(Self, 0, 0, login.Width, login.Height)[/quote]

It is relevant. There are certain things that you can’t do until the browser has actually drawn the control, because we don’t have a way to know what the actual size will be (due to things like locking).