Ne, geht nicht, da die PictureBox dann um das Bild herum verkleinert wird. Aber ich habe das jetzt hin bekommen:
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
' Aktuelles Bild an die Größe der PictureBox anpassen
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function CenterPictureInPictureBox(PictureBox As PictureBox)
Dim AutoRedraw As Boolean
Dim picNew As New StdPicture
Dim PictureWidth As Long
Dim PictureHight As Long
On Local Error Resume Next
Set picNew = PictureBox.Picture
With PictureBox
AutoRedraw = .AutoRedraw
.AutoRedraw = True
PictureWidth = PictureBox.ScaleX(PictureBox.Picture.Width, vbHimetric, vbTwips)
PictureHight = PictureBox.ScaleY(PictureBox.Picture.Height, vbHimetric, vbTwips)
Set PictureBox.Picture = Nothing
PictureBox.Cls
PictureBox.PaintPicture picNew, PictureBox.Width / 2 - PictureWidth / 2, PictureBox.Height / 2 - PictureHight / 2
.AutoRedraw = AutoRedraw
End With
End Function
Leider gibt es mit der Paint Methode ein Problem: Die Transparenz von Gif-Bildern wird falsch dargestellt!
Hat da jemand eine Möglichkeit, dies auch noch zu berücksichtigen?
Danke schon mal