Difference between revisions of "DesktopContainer"

From Xojo Documentation

 
Line 33: Line 33:
  
 
<dynamicTable id="Methods" super="DesktopWindow" class="methodTable" title="Methods" columns="3" exclude="Show,ShowModal,ShowModalWithin,ShowWithin,Minimize,Maximize,Restore">
 
<dynamicTable id="Methods" super="DesktopWindow" class="methodTable" title="Methods" columns="3" exclude="Show,ShowModal,ShowModalWithin,ShowWithin,Minimize,Maximize,Restore">
{{Method | name=EmbedWithin | params=ContainingWindow as [[DesktopWindow]], [left as [[Integer]], top as [[Integer]], width as [[Integer]], height as [[Integer]]] | description=EmbedWithin(ContainingWindow as [[DesktopWindow]], [left as Integer, top as Integer, width as Integer, height as Integer])&#x0A;Embeds the Container in a Window&#x0A;EmbedWithin(containingControl as DesktopUIControl, [left as Integer, top as Integer, width as Integer, height as Integer])&#x0A;Embeds a Container in another Container. }}
+
{{Method | name=EmbedWithin | params=ContainingWindow as [[DesktopWindow]], [left as [[Integer]], top as [[Integer]], width as [[Integer]], height as [[Integer]]] | description=EmbedWithin(ContainingWindow as DesktopWindow, [left as Integer, top as Integer, width as Integer, height as Integer])&#x0A;Embeds the Container in a Window&#x0A;EmbedWithin(containingControl as DesktopUIControl, [left as Integer, top as Integer, width as Integer, height as Integer])&#x0A;Embeds a Container in another Container. }}
{{Method | name=EmbedWithinPanel | params=ContainingPanel as [[DesktopPagePanel]], Page as [[Integer]], [left as [[Integer]], top as [[Integer]], width as [[Integer]], height as [[Integer]]] | description=EmbedWithinPanel(ContainingPanel as DesktopPagePanel,  Page as Integer, [left as Integer, top as Integer, width as Integer, height as Integer])&#x0A;Embeds the Container on a page in the passed PagePanel or TabPanel.  }}
+
{{Method | name=EmbedWithinPanel | params=ContainingPanel as [[DesktopPagePanel]], Page as [[Integer]], [left as [[Integer]], top as [[Integer]], width as [[Integer]], height as [[Integer]]] | description=EmbedWithinPanel(ContainingPanel as DesktopPagePanel,  Page as Integer, [left as Integer, top as Integer, width as Integer, height as Integer])&#x0A;Embeds the Container on a page in the passed PagePanel or TabPanel.  }}
 
</dynamicTable>
 
</dynamicTable>
  

Latest revision as of 00:19, 10 February 2022

Class (inherits from DesktopWindow)


New in 2021r3

Used to embed a group of controls in a Window or in another control.

Events
Closing FocusReceived MouseMove
ConstructContextualMenu KeyDown MouseUp
ContextualMenuItemSelected KeyUp MouseWheel
DragEnter MenuBarSelected Opening
DragExit MouseDown Paint
DragOver MouseDrag ScaleFactorChanged
DropObject MouseEnter
FocusLost MouseExit
Properties
AllowAutoDeactivate Handle fa-lock-32.png PanelIndex
AllowFocus HasBackgroundColor Parent
AllowFocusRing Height ScaleFactor fa-lock-32.png
AllowTabs Left TabIndex
Backdrop LockBottom Tooltip
BackgroundColor LockLeft Top
Bounds LockRight Transparent
Composited LockTop Visible
ControlCount fa-lock-32.png MouseCursor Width
Enabled MouseX fa-lock-32.png Window fa-lock-32.png
Focus MouseY fa-lock-32.png
Methods
AcceptFileDrop Close FocusNext
AcceptPictureDrop Control FocusPrevious
AcceptRawDataDrop Controls Hide
AcceptTextDrop DrawInto Refresh
AddControl EmbedWithin SetFocus
BitmapForCaching EmbedWithinPanel

Notes

fa-exclamation-circle-32.png
In the Layout Editor, do not layer other controls onto Containers that have been added to a Window layout. Controls added this way are not part of the Container and will not display properly. Instead, add your controls directly to the Container in its layout.
fa-exclamation-circle-32.png
Containers can not be part of a Control Set.

While DesktopContainer is a subclass of DesktopWindow, it should be thought of as a hybrid between DesktopWindow and DesktopUIControl. Like a DesktopWindow, a DesktopContainer can encapsulate related Controls (and other DesktopContainers) in a self-contained, reusable class. Like a DesktopUIControl, a DesktopContainer can be added to a DesktopWindow, a DesktopTabPanel, a DesktopPagePanel, or to another DesktopContainer.

You can embed a DesktopContainer in a DesktopWindow or DesktopContainer in either the IDE or via code. Multiple levels of embedding are supported.

To add the DesktopContainer to a window via code, use either the EmbedWithin or EmbedWithinPanel methods. Use EmbedWithin to embed the DesktopContainer in either a window or a control, depending on whether the first parameter is a DesktopWindow or a control. For the special case of embedding within a DesktopPagePanel or a DesktopTabPanel, use EmbedWithinPanel instead. It allows you to pass the page number on which the DesktopContainer will be embedded. To remove the container, use the Close method.

The following statement embeds a DesktopContainer at so that its top left corner is 50 points from the left side of the window and 100 points from the top.

Container1.EmbedWithin(Self, 50, 100)

When the project is run, the controls in the DesktopContainer appear in the default window, Window1. Use the same approach to embed the DesktopContainer in a control other than a DesktopPagePanel or DesktopTabPanel; for the latter types of controls, use EmbedWithinPanel and pass the name of the control and the desired panel number.

DesktopContainers 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, DesktopContainers act as you would expect. For example, if you put code in the MouseMove event of an embedded DesktopContainer, the event will fire when your mouse moves over the embedded DesktopContainer's boundaries. There are a few things you need to be aware of:

The Handle property of a DesktopContainer and the Handle property of controls of an DesktopContainer are Nil until the Opening event. All of the other properties can be manipulated before the Opening event.

A DesktopContainer either has its own keyboard focus and menu handling, or it shares these elements with its containing DesktopWindow. Which behavior is chosen depends on the state of the AllowFocus flag when the DesktopContainer is embedded. When AllowFocus is True, the DesktopContainer does not share focus with the containing DesktopWindow. 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 DesktopContainers and relate to its behavior when embedded; these behave like the corresponding properties of the DesktopCanvas control. These include the following: LockLeft, LockTop, LockRight, LockBottom, Enabled, AutoDeactivate, HelpTag, UseFocusRing, AllowFocus, AllowTabs, Parent and Window.

Miscellaneous Issues

Use the Opening event for initialization instead of overriding the Constructor to allow all the controls to finish setting themselves up.

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 DesktopContainers is allowed. However, you can't embed a DesktopContainer such that the containing DesktopContainer or a DesktopContainer higher in the containing chain is another instance of the same DesktopContainer; in other words, you can't recursively nest DesktopContainers in other instances of themselves.

Nested DesktopContainer 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 DesktopMenuItem's Popup method.

See Also

DesktopWindow classes