Article ID: 206907
Article Last Modified on 10/15/2002
Option Explicit
Private Sub form_load()
Label1.Left = 120
Label1.Top = 255
Label1.Height = 255
Label1.Width = 615
Label2.Left = 120
Label2.Top = 615
Label2.Height = 255
Label2.Width = 615
Text1.Left = 840
Text1.Top = 240
Text1.Height = 285
Text1.Width = 1215
Text2.Left = 840
Text2.Top = 600
Text2.Height = 285
Text2.Width = 1215
Command1.Left = 2160
Command1.Top = 240
Command1.Height = 285
Command1.Width = 2175
Command1.Caption = "Change Font Then Scale"
Command2.Left = 2160
Command2.Top = 600
Command2.Height = 285
Command2.Width = 2175
Command2.Caption = "Change Scale Then Font"
Form1.Left = 0
Form1.Top = 0
Form1.Height = 1560
Form1.Width = 4605
End Sub
Private Sub Command1_Click()
ChangeFont
ChangeScale
End Sub
Private Sub Command2_Click()
ChangeScale
ChangeFont
End Sub
Private Sub ChangeFont()
Dim fntNew As StdFont
Dim oControl As Object
Set fntNew = New StdFont
With fntNew
.Name = "MS Sans Serif"
.Size = 14
End With
On Error Resume Next
For Each oControl In Me.Controls
Set oControl.Font = fntNew
Next
End Sub
Private Sub ChangeScale()
Const FactorX = 1.77
Const FactorY = 1.85
Dim oControl As Object
On Error Resume Next
With Me
.Move 0, 0, .Width * FactorX, .Height * FactorY
For Each oControl In .Controls
With oControl
.Left = .Left * FactorX
.Top = .Top * FactorY
.Width = .Width * FactorX
.Height = .Height * FactorY
End With
Next
End With
End Sub
182070 HOWTO: Create a Resolution-Independent Form
Additional query words: FontSize
Keywords: kbbug kbpending KB206907