Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language:
Expertise: Beginner
Aug 6, 1997

Elastic Fonts

Designing monitor resolution-independent applications is a frequent problem Visual Basic programmers face. The simplest solution is to design forms at the 640 by 480 resolution found in most lap-top computers. Such a form design, however, looks awkward in desktop computers which have resolutions of 1024 by 768.

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

Should your forms require tabbed folders (in case of large number of 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 when the resolution of the monitor changes or when the form is resized. The remaining problem is that these custom controls cannot resize or reposition child controls that are pasted on frames, picture boxes, or panel controls (option buttons). As the custom controls do not alter the fontsize of the controls, captions are truncated. To overcome this problem, you need to use a true-proportional font such as Arial and insert this code in the Form_Resize event:

 
Sub Form_Resize()

dim i as integer, j as integer
dim curFormHeight as integer
dim curFormWidth as integer
dim DefaultFontSize as integer
dim orgFormHeight as integer
dim orgFormWidth as integer

On Error GoTo FormResizeError
DefaultFontSize = 8      
' Or whatever fancies you
orgFormHeight = 8000    
' In twips, or whatever your desired 
' height is
orgFormWidth = 8000

curFormHeight = Me.Height               
' Get current form height
curFormWidth = Me.Width          
' Get current form width

For 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 then
For 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 j

FormResizeError:
If Err = 438 Then
                Resume Next      ' If the form 
' contains a control whose Font  
' properties do not exist
End If



Sanjay Mawalkar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date