This calculation allows automatic resizing of controls at runtime. The change in size is based on the change in size of the parent form. An example of this is a List on a form. When the form is resized, the list needs to be longer or shorter in response to the parent window size changing. Another example might be a frame whose dimensions need to change but stay proportional to the parent window.
To work, the design time dimensions are captured on the form load. When the form size is changed, the original design time dimension and the current window dimension difference are used to change a control's size.
The advantage of the equation is that there are no rounding error accumulations or proportion distortions. The control size is to keep proportional to its design time layout but can expand to fill the form at runtime.
Variables to hold the design time values:
dclfld Design_ThisForm_Height type(*integer) len(4)
dclfld Design_ThisForm_Width type(*integer) len(4)
dclfld Design_Control_Height type(*integer) len(4)
dclfld Design_Control_Width type(*integer) len(4)
Initializing those variables to their values in an on load event:
BEGSR form Load
Design_ThisForm_Height = *ThisForm.Height
Design_ThisForm_Width = *ThisForm.Width
Design_Control_Height = Control.Height
Design_Control_Width = Control.Width
Endsr
And finally, resizing a control when a form size changes.
BEGSR form Resize
Control.Height= ( *thisform.Height - Design_ThisForm_Height) + Design_Control_Height
Control.Width = ( *thisform.Width - Design_ThisForm_Width ) + Design_Control_Width
Endsr