Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
This event fires each time an object is resized.
PROCEDURE oObject.Resize
[ LPARAMETERS nIndex ]
You can ignore the optional parameter to Resize unless you’re using Control Arrays
. If you are, read that section so we can convince you to stop.
A Resize event occurs each time a user resizes a container control whose properties allow resizing. A Resize event also occurs if the properties that control the size of a container (Height and Width) are changed programmatically. Classes based on any of the following “containing controls” have Resize events: Container, Control, Form, Grid, Column, OLEControl, OLEBoundControl, Pageframe and Toolbar. Different controls have different properties that determine if they can be resized interactively. For a column, the Resizable property has to be True. For a Form, BorderStyle must be set to 3. Sizable is the relevant property for the OLEControls. All the other objects must be resized programmatically for the Resize event to fire.
You might choose to refresh certain objects within a Resize event, such as ensuring that all buttons are still visible on a form, or shrinking text and label font sizes to fit a new column size. Resize events are a handy place for the code to resize or rearrange controls within a container. Check out the _resizable control that comes with the FoxPro Foundation Classes before trying to write your own.
One caution when resizing controls: Ensure that the container control hasn’t been shrunk too small to hold a control before changing the contained control’s properties, or an error could result. You might need to take advantage of the MinHeight and MinWidth properties of a form, or programmatically check limits for the other containers before manipulating contained objects.
Procedure Form1.Resize
* Move the Quit button to 50 pixels from the bottom of the form
ThisForm.cmdQuit.Top = ThisForm.Height - 50
* Center the button horizontally
ThisForm.cmdQuit.Left = .5 * (ThisForm.Width - ;
ThisForm.cmdQuit.Width)
*
* The form contains a custom edit box. It needs to take up all;
* space left to right except a margin and stretch itself to ;
* the height available on the form.
*
* Make the Width the form width less two margin widths
ThisForm.edtEditBox.width = ThisForm.Width - ;
2 * ThisForm.edtEditBox.Left
*
* Make the box height 108 pixels plus whatever room is ;
* available beyond the minimum form height
ThisForm.edtEditBox.Height = 108 + (ThisForm.Height - ;
ThisForm.MinHeight)
BorderStyle, Column, Container, Control, Control Arrays, Form, Grid, Height, MinHeight, MinWidth, OLEBoundControl, OLEControl, PageFrame, Resizable, Sizable, Toolbar, Width