mikymaxsp28
Messages postés30Date d'inscriptionlundi 22 janvier 2007StatutMembreDernière intervention18 septembre 2020
-
6 mai 2008 à 22:17
mikymaxsp28
Messages postés30Date d'inscriptionlundi 22 janvier 2007StatutMembreDernière intervention18 septembre 2020
-
6 mai 2008 à 22:19
Lors du redimensionnement des controls suite à l'agrandissement de la fenetre, le Top de ces controls devient négatif:
Dim tbl_taille() As tbl_taille 'Tableau de Type tbl_taille avec: Width, Height, Left, Top en variant
Dim e As Control
Dim largeur 'Largeur initial de la form
Dim hauteur 'Hauteur " " " "
Dim i
Dim n 'Nbr de control dans la form
Dim H 'Hauteur initial des controls
Dim W 'Largeur " " "
Dim L 'Left " " "
Dim T 'Top " " "
Private Sub Form_Load()
largeur = Form1.Width
hauteur = Form1.height
n = Form1.Count
ReDim tbl_taille(1 To n)
i = 1
'Attribut les dimenssion au tableau
For Each e In Form1
'La largeur et hauteur du CommandButton ne sont pas sauvegardés
If e.Name <> "cmd" Then
tbl_taille(i).witdh = e.Width
tbl_taille(i).height = e.height
End If
tbl_taille(i).top = e.top
tbl_taille(i).left = e.left
i = i + 1
Next
End Sub
Private Sub Form_Resize()
i = 1
For Each e In Form1
'Calcul le pourcentage occupé par les controls sur la form avant l'agrandissement
H = (e.height / hauteur) * 100
W = (e.Width / largeur) * 100
L = (e.left / largeur) * 100
T = (e.top / hauteur) * 100
'Redimensionne les controls
If Form1.Width > largeur - 1 Then
If e.Name <> "cmd" Then 'sauf pour le CommandButton
e.Width = (Form1.Width * W) / 100
End If
e.left = (Form1.Width * L) / 100
End If
If Form1.height > hauteur - 1 Then
If e.Name <> "cmd" Then 'sauf pour le CommandButton
e.height = (Form1.height * H) / 100
End If
e.top = (Form1.top * T) / 100
End If
i = i + 1
Next
End Sub
Voici un exemple sur la frame1 (Valeur en Twip):
avant resize
Height form = 7080
Width form = 10395
Height frame1 = 2775
Width frame1 = 1815
left frame1 = 480
top frame1 = 1200
apres resize
Height form = 13170
Width form = 21720
Height frame1 = 5162
Width frame1 = 3792
left frame1 = 1003
top frame1 = -10
Pouvez-vous me dire pourquoi?
et comment y remèdier.