Once you've set up layout constraints, you are ready to create a layout window in which you can lay out the children.
Here's the constructor for TLayoutWindow:
TLayoutWindow(TWindow* parent,
const char far*
title = 0, TModule* module = 0);
In this constructor,
- parent is the layout window's parent window.
- title is the layout window's title. This parameter defaults to a null string.
- module is passed to the TDialog base class constructor as the TModule parameter for that constructor. This parameter defaults to 0.
After the layout window is constructed and displayed, there are a number of functions you can call:
- The Layout function returns void and takes no parameters. This function tells the layout window to look at all its child windows and lay them out again. You can call this function to force the window to recalculate the boundaries and locations of each child window. You usually want to call Layout after you have moved a child window, resized the layout window, or done anything else that could affect the constraints of the child windows.
- Note
- TLayoutWindow overrides the TWindow version of EvSize to call Layout automatically whenever a WM_SIZE event is caught. If you override this function yourself, you should be sure either to call the base class version of the function or call Layout in your derived version.
- SetChildLayoutMetrics returns void and takes a TWindow & and a
- TLayoutMetrics & as parameters. Use this function to associate a set of constraints contained in a TLayoutMetrics object with a child window. Here is an example of creating a TLayoutMetrics object and associating it with a child window:
TMyLayoutWindow::TMyLayoutWindow(TWindow* parent,
char far*
title)
: TLayoutWindow(parent,
title)
{
}
#define lmParent
Use to represent the parent in layout metrics.
- Note
- The child window does not need any special functionality to be associated with a layout metrics object. The association is handled entirely by the layout window itself. The child window does not have to know anything about the relationship.
- GetChildLayoutMetrics returns a bool and takes a TWindow & and a TLayoutMetrics & as parameters. This function looks up the child window that is represented by the TWindow &. It then places the current layout metrics associated with that child window into the TLayoutMetrics object passed in. If GetChildLayoutMetrics does not find a child window that equals the window object passed in, it returns false.
- RemoveChildLayoutMetrics returns a bool and takes a TWindow & for a parameter. This function looks up the child window that represented by the TWindow &. It then removes the child window and its associated layout metrics from the layout window's child list. If RemoveChildLayoutMetrics does not find a child window that equals the window object passed in, it returns false.
You must provide layout metrics for all child windows of a layout window. The layout window assumes that all its children have an associated layout metrics object. Removing a child window from a layout window or deleting the child window object automatically removes the associated layout metrics object.