Private Sub lstImages_Click()
Dim Img, WX#, HX#, Ratio#
'lblNomActuel = txtChemin & "" & lstImages.List(lstImages.ListIndex)
lblNomActuel = "C:\Users\Public\Pictures\Sample Pictures\aaaa.jpg"
With WebBrowser1
.Navigate "about:blank"
Do While .ReadyState < 4: DoEvents: Loop
Set body = .Document.getelementsbytagname("body")(0)
With body.Style
.margin = "0"
.Width = "100%"
.Height = "100%"
End With
Set Img = .Document.createelement("img")
Img.src = lblNomActuel
Img.ID = "MyImg"
With Img.Style
.display = "block"
.MarginLeft = "auto"
.MarginRight = "auto"
.Position = "absolute" ' sans ca on ne peut mettre une image ailleur qu'a gauche
WebBrowser1.Document.body.appendchild (Img)
' c'est maintenant que l'on s'amuse
' on calcule le ratio width et height du body/image
WX = body.ClientWidth / Img.offsetwidth
HX = body.ClientHeight / Img.offsetheight
Ratio = Application.Min(WX, HX) ' on prend le plus petit
Img.Width = (Img.offsetwidth * Ratio) - 6 'on applique a l'image - le 6 car j'ai enlever la marge du body(plein webbrowser)
Img.Height = (Img.offsetheight * Ratio) - 6 'pareil
.Left = (body.ClientWidth - Img.Width - 6) / 2 'on la centre
End With
' voir le code en bon et due forme d'une balise Img html
TextBox1 = .Document.getelementsbytagname("body")(0).outerhtml
End With
Set Img = Nothing
End Sub
Private Sub UserForm_Click()
End Sub