Scaling in Forms

Description

In general, most properties of a form are stored and returned in pixels (there are one or two oddities such as Width and Height which are returned in Twips, but these are rare), with coordinates starting from zero on the x- and y-axes. However, this may not always suit how you wish to display controls and GDI objects in a form and so, in common with Visual Basic, GFABASIC32 offers the option to create a customised coordinate system, or Scale, so the form better suits what you, as the programmer, which to achieve.

Scaling is implemented by the changing of the scaling factor - the size of the standard unit of measurement - and of the starting coordinates on one or both axes. In addition, changes can be made to scaling at any point of the drawing of the form: those objects drawn before the changes keep their original scaling whilst those drawn afterwards adopt the new attributes.

Note: For form scaling to affect OCX Controls, the OcxScale property of the form must be set to True.

Changing Scaling Factors

ScaleMX, ScaleMY properties Show


ScaleWidth, ScaleHeight properties Show


ScaleMode property and ScaleMode$ function Show

 

Changing Starting Coordinates

ScaleLeft, ScaleTop properties and OffsetXY command Show

 

Changing Both

Scale method Show


ScaleMMOO function Show

 

Manual Scaling & Conversion

If you do not wish to permanently affect the scaling factor of a form, GFABASIC32 has numerous functions that allow you to perform one-off conversion between different measurement types, some of which are listed below:

ScaleX, ScaleY These functions allow conversion between Twips, Points, Pixels, Characters, Inches, Millimetres, Centimetres, and HiMetrics; in addition, when used in a scaled form, they can convert between the current user-defined scaling and the standard measurements listed above.
TwipsPerHimet, HimetsPerTwips Screen object properties, these allow conversion between Twips and HiMetrics.
HimetsToPixelX, HimetsToPixelY, PixelsToHimetX, PixelsToHimetY Built-in functions that convert between HiMetrics and Pixels on both the X and Y planes.
TwipsPerPixelX, TwipsPerPixelY, PixelsToTwipX, PixelsToTwipY The first two are Screen and Form based properties, the last two built-in functions: all allow conversion from Pixels to Twips along the specified plane or axis.
PixelsPerTwipX, PixelsPerTwipY, TwipsToPixelX, TwipsToPixelY As with those above but converting from Twips to Pixels.

See Also

ScaleToDPi, ScaleXYWHToDpi, WM_DPICHANGED, WorkWidth, WorkHeight.

{Created by James Gaite; Last updated: 02/03/2022 by James Gaite; Other Contributors: Jean-Marie Melanson}