Return or set the position and dimensions of an Ocx object or a Window.
object.Left [= value]
object.Top [= value]
object.Height [= value]
object.Width [= value]
object:Ocx objects
value:Single exp
The Left and Top properties set the position of an OCX control, Form or Window, the Height and Width properties, its outer dimensions.
For Windows created with the OpenW and Form commands, these values are given and returned in Twips, for OCX objects in Pixels (see Remarks).
In addition, Height and Width are also used with the Screen and Printer properties: For the Screen object they return the height and width of the screen, while for the Printer object, the physical dimensions of the paper set up for the printing device. If these properties are used to set dimensions in the Printer object, these values are used instead of the setting of the PaperSize property.
Form Frm
Do
Sleep
Until Me Is Nothing
Sub Frm_Click ()
With Frm
.Width = Screen.Width * .75 // Set width of form.
.Height = Screen.Height * .75 // Set height of form.
.Left = (Screen.Width - .Width) / 2 // Center form horizontally.
.Top = (Screen.Height - .Height) / 2 // Center form vertically.
End With
End Sub
This example sets the size of a form to 75 percent of screen size and centers the form when it is loaded.
If a function needs to handle the dimensions of all three types of form or window - those created using the OpenW, Form and Ocx Form - this can not be done within GB32 as it is impossible to determine from its properties how a form or window was created; in this instance, it is advised that you use one or a combination of the GetWindowRect, GetClientRect or GetWinRect APIs. Alternatively, see Remarks on the Forms/Ocx Forms page.
Form, Move, OcxScale, ScaleMode
{Created by Sjouke Hamstra; Last updated: 07/08/2022 by James Gaite}