Copyright: ®1995 Beond Technology Corp.


  TStretchPanel Component

Properties	Using TStretchPanel	Additional Information.

Description

TStretchPanel is a Delphi component which resizes any control placed on it. It inherits all properties from the standard TPanel supplied with Delphi and adds 5 more: Anchors, KeepAspect, MinDimension, StretchControls, and StretchFonts.

The StretchControls property is the primary triggerif it is False, the component behaves as a TPanel.

With StretchControls = True and default operation (no anchors and KeepAspect = NoAspect), all controls placed in the TStretchPanel are resized in proportion to the change in the panel. Controls get taller/shorter and wider/thinner in proportion to the equivalent change in the containing panel, with their relative positions adjusted to keep the same proportional space from the edges of the panel.

It is much easier to see this in action than to describe it...play with the component in design mode to see how it works. Place a TStretchPanel into a new form, set its alignment to client and, with StretchControls = False, place some controls on it. Then change StretchControls to True and resize the form.


TStretchPanel Properties
Anchors

KeepAspect

MinDimension

StretchControls

StretchFonts


  Using The TStretchPanel Component

Place a TStretchPanel on a form anywhere that you would place a TPanel, then place controls on the TStretchPanel. After setting the position of all controls, go to the Object Inspector and set the StretchControls property  to True to enable automatic sizing of controls. Set StretchFonts to True to also enable automatic stretching of fonts.

StretchControls is the primary trigger--if it is False, the component behaves as a TPanel.

With StretchControls = True and default operation (all Anchors = False and KeepAspect = NoAspect), all controls placed in the TStretchPanel are resized in proportion to the change in the panel. Controls get taller/shorter and wider/thinner in proportion to the equivalent change in the containing panel, with their relative positions adjusted to keep the same proportional space from the edges of the panel.

It is possible to place a TStretchPanel on another TStretchPanel; resizing either the owner or owned panel will stretch the controls within the owned panel.

See also:

Anchors

KeepAspect

MinDimension

StretchControls

StretchFonts


Anchors property

Declaration

property TAnchor = (AnchorLeft, AnchorTop, AnchorRight, AnchorBottom);

TAnchors = set of TAnchor;

The Anchors property is used to anchor the controls in a TStretchPanel to one or more of the panel's edges. If True, an anchor keeps the control's distance from the edge of its enclosing TStretchPanel the same after resizing as it was before it was resized.

In other words, each control is anchored to the indicated side of the panel. All, any or none of the edges can be anchored. If all edges are anchored, controls grow and shrink toward the inside of their TStretchPanel.

Anchors can cause controls to extend past the edge of a panel when resized. Be sure to experiment to make sure the panel is doing what you want.

AnchorLeft

Keeps distance between left side of controls and left edge of TStretchPanel the same after resizing as it was before resizing.

AnchorTop

Keeps distance between top of controls and top of TStretchPanel the same after resizing as it was before resizing.

AnchorRight

Keeps distance between right side of controls and right edge of TStretchPanel the same after resizing as it was before resizing.

AnchorBottom

Keeps distance between bottom of controls and bottom of TStretchPanel the same after resizing as it was before resizing.


KeepAspect property

Declaration

property KeepAspect: TKeepAspect;

TKeepAspect = (NoAspect, WidthBased, HeightBased);

If you want the controls in a TStretchPanel to keep their width-to-height ratio even if the enclosing panel is not resized that way, choose WidthBased or HeightBased.

HeightBased

Resizing of controls by adjusting a control's width based on a change in its height.

NoAspect

Resizing of controls proportional to the change in width and height of their TStretchPanel's size change.

WidthBased

Resizing of controls by adjusting a control's height based on a change in its width.

The "based" change is the change proportional to TStretchPanel's size change. If you choose WidthBased and a TStretchPanel shrinks by 10% width 30% height, its controls shrink by 10% in width and height.

This property has a higher priority than any other (except StretchControls). To see operation, select WidthBased or HeightBased then make a panel only wider and only taller. WidthBased and HeightBased KeepAspect can cause controls to extend past the edge of a panel when resized.


MinDimension property

Declaration

property MinDimension: LongInt;

To prevent controls from shrinking to zero size, set a minimum dimension (width and/or height) for all controls. When any control attempts to get smaller than this, the resizing of the TStretchPanel and its controls is cancelled. Default value is 1; acceptable values are 1 and higher.


StretchControls property

Declaration

property StretchControls: Boolean;

The "on/off" switch for resizing a panel's controls. True is on (controls are stretched) and False is off. If StretchControls = False, all Anchors and StretchFonts are inactive even if set to True.

A "control" is most of Delphi's visible control components such as TListbox, TEdit, TStatic, TDBEdit, TMemo, TDBMemo, etc. and their descendants.


StretchFonts property

Description

property StretchFonts: Boolean;

If you wish to have a TStretchPanel's controls' fonts change size in proportion to the change in the panel's height, set this property to True. Any control on the TStretchPanel whose ParentFont property is set to True will have its fonts resized. Set the TStretchPanel's font to set the fonts of controls it contains.

Note that fonts are only resized in proportion to TStretchPanels vertical (height) changes; width changes have no effect on font size.

This property is ignored if StretchControls = False.


Additional Information
TStretchPanel Component for Delphi
©1995 by Beond Technology Corp. All Rights Reserved

Design Only version

If your TStretchPanel only works in design mode, you can get the fully functional version from CompuServe's shareware forum (GO SWREG and search for STRETCH) or from:

Beond Technology Corp.
15370 W. Cherrywood Lane
Libertyville, IL 60048-1435
(708) 918-7750 (V/F)
CompuServe: 76640,2664
Internet: brianlow@mcs.com

Limited Warranty

Because you can completely evaluate it before you buy it, this software has no warranty whatsoever. This nonwarranty is in lieu of any other warranty, expressed or implied, including the implied warranties of merchantability and fitness for a particular purpose. In no event will Beond Technology Corp. be liable to you for damages, including any loss of profits, lost savings, or other incidental or consequential damages arising out of your use of or inability to use the software.

Support

At the price, you can't expect much support...if you find a real bug, e-mail me. If you want a modified version and are willing to pay for development, e-mail me. A response to other queries is unlikely but you are welcome to try.