Can I add a control to a window from another window

Is there a way to add a control to a window at run time from a method in another window?

Basically is there a way to add controls to dynamically created windows?

http://developer.xojo.com/userguide/desktop-control-sets

From the LR I take it’s not possible to add a control to a dynamically created window?

For example I can’t do this?

Dim W as new Window Dim C as new PushButton 'how to put the button in the new window? W.show

The window that you “new” in the above code should be of a type already created in the IDE.

Dim w as new myCreatedWnd

The myCreatedWnd should already contain at least 1 control previously created of type pushbutton
You then use the techniques outlined In the link Norman provided to create as many other myBtns as you need. I would not do that from your original screen, but rather from myCreatedWnd.

Yes, you can do it. You have 2 options:

Control Set
ContainerControl

[quote=338157:@Neil Burkholder]From the LR I take it’s not possible to add a control to a dynamically created window?

For example I can’t do this?

Dim W as new Window Dim C as new PushButton 'how to put the button in the new window? W.show[/quote]

Not like that no

The doc on control sets details one way to do it

So basically in order for controls to be added to a window it needs to already have a control set of that type added to an instance of a window in the IDE?

That’s not an instance, that’s a class definition in the IDE. When you show it (or use New), then you get an instance at runtime. I know that may be splitting hairs, but it might be helpful in getting a proper mental framework.

If you want to start from a completely generic Window, then you have 1 option:

ContainerControl

These two thread are kind of running together. Thanks Norman for your explanation. That really helps me put it together.

[quote=338183:@Norman Palardy]“instance” might not be the right name for the ones you CAN edit the layout in the IDE
Perhaps “template” is a better way to describe them
[/quote]

“template” is a better word because they aren’t classes like adding one from Insert > New Class

its why “Insert > Window” gives you an item that cannot be placed in a Module - but you can edit its UI
yet “Insert > Class” and changing the super to “Window” you CAN put in a module but cannot edit UI

its all kinds of fun

All the abstraction is nice, but sometimes it is good to have an understanding of how things work.

http://web.archive.org/web/20080321004712/http://ramblings.aaronballman.com/2007/06/windows_a_weird_odyssey.html

While this was written a decade ago its still “the truth”

And for anyone interested you can buy a copy of Aaron’s book Ramblings on REALbasic which is still full of useful stuff like this