From Xojo Documentation
- For web apps, see WebContainer.
|In the Layout Editor, do not layer other controls onto ContainerControls that have been added to a Window layout. Controls added this way are not part of the ContainerControl and will not display properly. Instead, add your controls directly to the ContainerControl in its layout.|
|ContainerControls can not be part of a Control Set.|
ContainerControl is not a Control (despite its name), nor is it a Window. It is a separate class that is similar to Control and to Window, providing many of the same events, properties, and methods. Like a Window, a ContainerControl can encapsulate related Controls (and other ContainerControls) in a self-contained, reusable class. Like a Control, a ContainerControl can be added to a Window, a TabPanel, a PagePanel, or to another ContainerControl.
You can embed a ContainerControl in a Window or ContainerControl in either the IDE or via code. Multiple levels of embedding are supported.
To add the ContainerControl to a window via code, use either the EmbedWithin or EmbedWithinPanel methods. Use EmbedWithin to embed the ContainerControl in either a window or a control, depending on whether the first parameter is a Window or a control. For the special case of embedding within a PagePanel or a TabPanel, use EmbedWithinPanel instead. It allows you to pass the page number on which the ContainerControl will be embedded. To remove the container, use the Close method.
The following statement embeds a ContainerControl at so that its top left corner is 50 points from the left side of the window and 100 points from the top.
When the project is run, the controls in the ContainerControl appear in the default window, Window1. Use the same approach to embed the ContainerControl in a control other than a PagePanel or TabPanel; for the latter types of controls, use EmbedWithinPanel and pass the name of the control and the desired panel number.
ContainerControls have multiple uses, You can:
Organize groups of controls into reusable interface components,
Create custom controls made up of several constituent controls,
Increase encapsulation of complex window layouts,
Create dynamic layouts.
For the most part, ContainerControls act as you would expect. For example, if you put code in the MouseMove event of an embedded ContainerControl, the event will fire when your mouse moves over the embedded ContainerControl's boundaries. There are a few things you need to be aware of:
The Handle property of a ContainerControl and the Handle property of controls of an ContainerControl are Nil until the Open event. All of the other properties can be manipulated before the Open event.
A ContainerControl either has its own keyboard focus and menu handling, or it shares these elements with its containing Window. Which behavior is chosen depends on the state of the AllowFocus flag when the ContainerControl is embedded. When AllowFocus is True, the ContainerControl does not share focus with the containing Window. If a containing window has embedded that which share focus with it, those windows will get a first crack at handling it. If none handle it, the containing window will get a try. This applies to KeyDown and MenuCommands. It also affects how menu commands are enabled.
Some properties are new to ContainerControls and relate to its behavior when embedded; these behave like the corresponding properties of the Canvas control. These include the following: LockLeft, LockTop, LockRight, LockBottom, Enabled, AutoDeactivate, HelpTag, UseFocusRing, AllowFocus, AllowTabs, Parent and Window.
The Moved, Resized, and Resizing events fire on embedded windows when the embedded window is moved or resized.
The Show/Hide and the Visible property can be used to set the visibility of embedded windows.
Nesting ContainerControls is allowed. However, you can't embed a ContainerControl such that the containing ContainerControl or a ContainerControl higher in the containing chain is another instance of the same ContainerControl; in other words, you can't recursively nest ContainerControls in other instances of themselves.
Nested ContainerControl coordinates for controls and events are automatically transformed for you. You don't need to worry about them unless you are dealing with global coordinates as you would for the MenuItem's Popup method.