Meilleur auteur de réponses
redimensionnement automatique

Question
-
Réponses
-
Bonjour Julien,
Voici un exemple testé :
Option Explicit On Public Class Form1 Dim ratio As Double Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.Left = 0 ' Placement initial pour l'exemple Me.Top = 0 Me.Width = 400 Me.Height = 200 Button1.Left = 50 ' bouton faire varier selon variation form Button1.Top = 50 Button1.Width = 100 Button1.Height = 25 Button1.Font = New System.Drawing.Font("Courier New", 11, FontStyle.Regular) If Me.Width > Button1.Width Then ratio = (Button1.Width / Me.Width) + 1 ' exemple de prise de ratio End Sub Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click ' A CHAQUE APPUI ÇA AUGMENTE EN TAILLE DANS CET EXEMPLE ' exemple très théorique, souvent il faut plusieurs ratios s'il y a des nombreux objets Me.Width = Me.Width + 200 ' je double la taille de mon écran Me.Height = Me.Height + 100 ' pour ne pas dépasser l'écran : x et y donnent la dimension de l'écran Dim x As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width If x < Me.Width Then Me.Width = x Dim y As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height If y < Me.Height Then Me.Height = y ' application du ratio au bouton If Me.Width < x Then Button1.Left = Button1.Left * ratio Button1.Width = Button1.Width * ratio Dim taillePo As Integer = 11 ' taille police de base taillePo = Int(taillePo * ratio) Button1.Font = New System.Drawing.Font("Courier New", taillePo, FontStyle.Regular) End If If Me.Height < y Then Button1.Top = Button1.Top * ratio Button1.Height = Button1.Height * ratio End If End Sub End Class
Cordialement.
Joseph Attila PUSZTAY
EhJoe Logiciels Romans Ecrire- Proposé comme réponse EhJoe mercredi 11 janvier 2012 09:27
- Marqué comme réponse Julien Prest mercredi 11 janvier 2012 10:36
Toutes les réponses
-
Bonjour Julien,
Voici un exemple testé :
Option Explicit On Public Class Form1 Dim ratio As Double Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.Left = 0 ' Placement initial pour l'exemple Me.Top = 0 Me.Width = 400 Me.Height = 200 Button1.Left = 50 ' bouton faire varier selon variation form Button1.Top = 50 Button1.Width = 100 Button1.Height = 25 Button1.Font = New System.Drawing.Font("Courier New", 11, FontStyle.Regular) If Me.Width > Button1.Width Then ratio = (Button1.Width / Me.Width) + 1 ' exemple de prise de ratio End Sub Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click ' A CHAQUE APPUI ÇA AUGMENTE EN TAILLE DANS CET EXEMPLE ' exemple très théorique, souvent il faut plusieurs ratios s'il y a des nombreux objets Me.Width = Me.Width + 200 ' je double la taille de mon écran Me.Height = Me.Height + 100 ' pour ne pas dépasser l'écran : x et y donnent la dimension de l'écran Dim x As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width If x < Me.Width Then Me.Width = x Dim y As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height If y < Me.Height Then Me.Height = y ' application du ratio au bouton If Me.Width < x Then Button1.Left = Button1.Left * ratio Button1.Width = Button1.Width * ratio Dim taillePo As Integer = 11 ' taille police de base taillePo = Int(taillePo * ratio) Button1.Font = New System.Drawing.Font("Courier New", taillePo, FontStyle.Regular) End If If Me.Height < y Then Button1.Top = Button1.Top * ratio Button1.Height = Button1.Height * ratio End If End Sub End Class
Cordialement.
Joseph Attila PUSZTAY
EhJoe Logiciels Romans Ecrire- Proposé comme réponse EhJoe mercredi 11 janvier 2012 09:27
- Marqué comme réponse Julien Prest mercredi 11 janvier 2012 10:36
-