Share via


Resize and Reposition Controls at Run Time Sample

File: ...\Samples\Solution\Forms\Cresize.scx

A user can resize this sample form as desired. The controls on the form are resized or repositioned relative to the new Height and Width properties of the form.

This form uses the resizable class in ...\Samples\Classes\Samples.vcx to manage resizing and repositioning of the controls. The following line of code is added to the Resize event of the form, calling the AdjustControls method of the resizable class:

THIS.Resizable2.AdjustControls

In the Init of the resizable class, code loops through all the controls in the form, storing their positions and sizes relative to the form in an array. When the form is resized, the AdjustControls method resizes and repositions the controls to their relative sizes and positions.

You can add more controls to the form and the new controls will also be resized and repositioned.

The RepositionList and ResizeList properties contain a space-delimited list of all the classes that you want to reposition and resize. If you do not want a certain class to be resized, remove it from the ResizeList.

You can prevent a user from making the form too small for the objects contained on it by setting the form's MinHeight and MinWidth properties.

See Also

Tasks

Allow Users to Drag and Drop Controls Sample

Hot Tracking and Hover Effects Sample

Reference

Resize Object Foundation Class

Other Resources

Controls Solution Samples