'I give you a cursus Windows resize ;-)
' Add a Module to a project
' declarations :
Option Explicit
Public Xtwips As Integer, Ytwips As Integer
Public Xpixels As Integer, Ypixels As Integer
Type FRMSIZE
Height As Long
Width As Long
End Type
Public Positie_Form As Boolean
Public NuResize As Boolean
Dim DesignX As Integer
Dim DesignY As Integer
Dim ScaleFactorX As Single, ScaleFactorY As Single
Dim MyForm As FRMSIZE
'Copy next procedures in the module
Public Sub FormResize(TheForm As Form)
Dim ScaleFactorX As Single, ScaleFactorY As Single
If Not NuResize Then
NuResize = True
Exit Sub
End If
Positie_Form = False
ScaleFactorX = TheForm.Width / MyForm.Width
ScaleFactorY = TheForm.Height / MyForm.Height
Resize_Resolutie ScaleFactorX, ScaleFactorY, TheForm
MyForm.Height = TheForm.Height
MyForm.Width = TheForm.Width
End Sub
Sub Resize_Resolutie(ByVal SFX As Single, ByVal SFY As Single, MyForm As Form)
Dim I As Integer
Dim SFFont As Single
SFFont = (SFX + SFY) / 2
On Error Resume Next
With MyForm
For I = 0 To .Count - 1
If TypeOf .Controls(I) Is ComboBox Then
.Controls(I).Left = .Controls(I).Left * SFX
.Controls(I).Top = .Controls(I).Top * SFY
.Controls(I).Width = .Controls(I).Width * SFX
Else
.Controls(I).Move .Controls(I).Left * SFX, _
.Controls(I).Top * SFY, _
.Controls(I).Width * SFX, _
.Controls(I).Height * SFY
End If
If TypeOf .Controls(I) Is DBGrid Then
Else
.Controls(I).FontSize = .Controls(I).FontSize * SFFont
End If
Next I
If Positie_Form Then
.Move .Left * SFX, .Top * SFY, .Width * SFX, .Height * SFY
End If
End With
End Sub
Public Sub SizeForm(TheForm As Form)
Dim Resolut As String ' voor de resolutie waarde van het systeem
' gebruik de design resolutie van je system (800 - 600 )
DesignX = 1024
DesignY = 768
Positie_Form = True
NuResize = False
Xtwips = Screen.TwipsPerPixelX
Ytwips = Screen.TwipsPerPixelY
Ypixels = Screen.Height / Ytwips
Xpixels = Screen.Width / Xtwips
ScaleFactorX = (Xpixels / DesignX)
ScaleFactorY = (Ypixels / DesignY)
TheForm.ScaleMode = 1
Resize_Resolutie ScaleFactorX, ScaleFactorY, TheForm
Resolut = Str$(Xpixels) + " by " + Str$(Ypixels)
MyForm.Height = TheForm.Height
MyForm.Width = TheForm.Width
End Sub
'add next code to the form
Option Explicit
Private Sub Form_Load()
Call SizeForm(Me)
End Sub
Private Sub Form_Resize()
Call FormResize(Me)
End Sub
'Cheers Eric De Decker
vbg.be@vbgroup.nl
Licence And Copy Protection AxtiveX
Source CodeBook for the programmer