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.
These properties, not surprisingly, control the height and width of visual objects, including forms and controls.
oObject.Height = nValue
nValue = oObject.Height
oObject.Width = nValue
nValue = oObject.Width
The size of an object is measured in the current ScaleMode.
Height and Width are measured differently from each other and differently for different objects. For forms, Height and Width exclude borders and titles. For controls, Height includes the border, but Width is measured from the center of the border. According to the docs, measuring a control’s width this way makes it easier to line up controls with different borders. We’re not sure we see the point.
You can change the size of an object by modifying Height and Width. However, controls contained in grid columns can’t be resized.
frmMyForm = CREATEOBJECT("form")
frmMyForm.SHOW()
frmMyForm.Height = frmMyForm.Height + 20
frmMyForm.Width = frmMyForm.Width * 1.5
The example demonstrates that you can make changes relative to existing values. You can use this ability to size contained objects to fit inside the container—for example, making sure a certain set of controls fits into a form.
* Resize Demo
frmResizeDemo = CREATEOBJECT("ResizeForm")
frmResizeDemo.Show()
READ EVENTS
DEFINE CLASS ResizeForm as Form
ScaleMode = 0 && Note that this is foxels for simplicity
MinHeight = 10
Add Object edtNote as Speech
Add Object btnQuit as QuitButton
* Custom Properties
nQuitBtnMargin = 3
nEdtBoxMargin = 5
PROCEDURE Init
This.ReSize()
ENDPROC
Procedure ReSize
ThisForm.btnQuit.Top = ThisForm.Height - This.nQuitBtnMargin
ThisForm.btnQuit.Left = (ThisForm.Width - ;
ThisForm.btnQuit.Width ) / 2
ThisForm.edtNote.Height = ThisForm.Height - ;
ThisForm.nEdtBoxMargin
ThisForm.edtNote.Width = ThisForm.Width - ;
2*ThisForm.edtNote.Left
ENDPROC
PROCEDURE Destroy
CLEAR EVENTS
ENDPROC
ENDDEFINE
DEFINE CLASS QuitButton AS CommandButton
Caption="Quit"
HEIGHT = 2
PROCEDURE Click
CLEAR EVENTS
ENDPROC
ENDDEFINE
DEFINE CLASS Speech AS EditBox
Left = 3
Value = "Four score and seven years ago " + ;
"our fathers brought forth on " + ;
"this continent a new nation, conceived " + ;
"in liberty and dedicated to the proposition " + ;
"that all men are created equal."
ENDDEFINE
For a form, Height and Width are constrained by MaxHeight, MinHeight, MaxWidth and MinWidth. Regardless of the values you assign, the Height and Width will never go beyond those boundaries.
Left, Top, MaxHeight, MaxWidth, MinHeight, MinWidth, ScaleMode