devxlogo

Elastic Fonts

Elastic Fonts

Designing monitor resolution-independent applications is a frequentproblem Visual Basic programmers face. The simplest solution isto design forms at the 640 by 480 resolution found in most lap-topcomputers. Such a form design, however, looks awkward in desktopcomputers which have resolutions of 1024 by 768.

Solutions to resolve this include VSElastic control from VideoSoft’sVS-OCX and FarPoint’s Tab Pro VBX. In VSElastic, you can pasteall child controls on the Elastic control. You must adjust thecontrol’s two properties, Align = 5 (Fill Container, here theform itself) and AutosizeChildren = 7 (Proportional).

Should your forms require tabbed folders (in case of large numberof controls), use Tab Pro and set the AutoSize = 5 (Fill Parent)and AutosizeChildren = 3 (size and location of control).

The controls now will automatically resize and reposition whenthe resolution of the monitor changes or when the form is resized.The remaining problem is that these custom controls cannot resizeor reposition child controls that are pasted on frames, pictureboxes, or panel controls (option buttons). As the custom controlsdo not alter the fontsize of the controls, captions are truncated.To overcome this problem, you need to use a true-proportionalfont such as Arial and insert this code in the Form_Resize event:

 Sub Form_Resize()dim i as integer, j as integerdim curFormHeight as integerdim curFormWidth as integerdim DefaultFontSize as integerdim orgFormHeight as integerdim orgFormWidth as integerOn Error GoTo FormResizeErrorDefaultFontSize = 8      ' Or whatever fancies youorgFormHeight = 8000    ' In twips, or whatever your desired ' height isorgFormWidth = 8000curFormHeight = Me.Height               ' Get current form heightcurFormWidth = Me.Width          ' Get current form widthFor i = 0 to Controls.Count -1                Controls(i).FontName = "Arial"                Controls(i).FontSize = _                        DefaultFontSize * _                        (curFormHeight / _                        orgFormHeight)Next i' If the form contains option buttons or 'check box control group thenFor j = 0 To Option1().Count - 1                Option1(j).Height = 200 * _(curFormHeight / orgFormHeight)                Option1(j).Width = 1000 * _(curFormWidth / orgFormWidth)                Option1(j).Top = 250 * _                        (j + 1) * (curFormHeight _                        / orgFormHeight)                Option1(j).Left = 250 * _                        (curFormWidth / orgFormWidth)   Next jFormResizeError:If Err = 438 Then                Resume Next      ' If the form ' contains a control whose Font  ' properties do not existEnd If
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist