[VB 6.0]interface proportionnelle à l'écran

cs_med_ali Messages postés 23 Date d'inscription vendredi 18 mars 2005 Statut Membre Dernière intervention 2 avril 2011 - 19 juil. 2005 à 20:34
jpleroisse Messages postés 1788 Date d'inscription mardi 7 novembre 2000 Statut Membre Dernière intervention 11 mars 2006 - 19 juil. 2005 à 21:01
comment je peut assurer qu'une interface soit de dimention proportionnelle à celle de l'écran avec bien sûr tous ses controles

1 réponse

jpleroisse Messages postés 1788 Date d'inscription mardi 7 novembre 2000 Statut Membre Dernière intervention 11 mars 2006 27
19 juil. 2005 à 21:01
Bonsoir,

Essaie ceci: (presonnelement, je ne l'ai pas encore essayé)



Private Sub Form_Load()

'Résolution correspondant à la form telle qu'elle est en mode conception

Const ResolutionRefX As Long = 640

Const ResolutionRefY As Long = 480 'Rapport entre la résolution actuelle et celle de référence

Dim RatioX As Single

Dim RatioY As Single 'Résolution actuelle

Dim ResolutionX As Long

Dim ResolutionY As Long

ResolutionX Screen.Width / Screen.TwipsPerPixelX ResolutionY Screen.Height / Screen.TwipsPerPixelY

RatioX ResolutionX / ResolutionRefX RatioY ResolutionY / ResolutionRefY 'Adapte les dimensions en fonction de la résolution actuelle

ResizeForResolution RatioX, RatioY

End Sub



Private Sub ResizeForResolution(ByVal RatioX As Single, ByVal RatioY As Single)

Dim ctl As Control

Dim RatioPolices As Single

RatioPolices (RatioX + RatioY) / 2 Me.Width Me.Width * RatioX Me.Height = Me.Height * RatioY

For Each ctl In Me.Controls

If TypeOf ctl Is ComboBox Then

ctl.Move ctl.Left * RatioX, ctl.Top * RatioY, ctl.Width * RatioX

Else

ctl.Move ctl.Left * RatioX, ctl.Top * RatioY, ctl.Width * RatioX, ctl.Height * RatioY

End If

If TypeOf ctl Is Label Then

ctl.FontSize = ctl.FontSize * RatioPolices

Next

End Sub



jpleroisse
0
Rejoignez-nous