Hallo Leute ich hab ein Problem mit einem Hitnergrundbild auf einer MDI Form
Das Laden des Bilder ist ja kein Thema aber ich will das Bild stretchen damit es den gesamten MDI Form Hintergrund nutzt ich verwende diesen Code aus einem VB Tipp:
' Parameter:
' ----------
'
' picContainer: Form oder PictureBox-Control
' pic : anzuzeigendes Bild
' bStretch : Optional. True, wenn ein kleines Bild
' an die Größe des Containers angepasst
' werden soll.
' bCenter : Optional. True, wenn das Bild innerhalb
' des Bild-Containers zentriert angezeigt
' werden soll.
' lBackColor : Optional. Hintergrundfarbe des
' Bild-Containers
' =====================================================
Public Sub Picture_Show(picContainer As Object, _
pic As Picture, _
Optional ByVal bStretch As Boolean = True, _
Optional ByVal bCenter As Boolean = True, _
Optional ByVal lBackColor As Long)
Dim picWidth As Long
Dim picHeight As Long
Dim picLeft As Long
Dim picTop As Long
Dim contAspectRatio As Single
Dim picAspectRatio As Single
With picContainer
' Größenverhältnis Container (Breite : Höhe)
contAspectRatio = .ScaleWidth / .ScaleHeight
' Bild-Größe + Größen-Verhältnis
' Die Problemstelle:
picWidth = .ScaleX(pic.Width, 8, .ScaleMode)
picHeight = .ScaleY(pic.Height, 8, .ScaleMode)
picAspectRatio = picWidth / picHeight
'----------------------------------------------------------------------
' Bild anpassen?
If (picWidth > .ScaleWidth Or picHeight > .ScaleHeight) Or (bStretch) Then
' Größenverhältnis des Bildes ist kleiner als
' das des Containers
If picAspectRatio <= contAspectRatio Then
' Bildbreite muss angepasst werden
picWidth = picWidth / (picHeight / .ScaleHeight)
picHeight = .ScaleHeight
' Left-Position
If bCenter Then
picLeft = Int((.ScaleWidth - picWidth) / 2)
End If
' Größenverhältnis des Bildes ist größer als
' das des Containers
Else
' Bildhöhe muss angepasst werden
picHeight = picHeight / (picWidth / .ScaleWidth)
picWidth = .ScaleWidth
' Top-Position
If bCenter Then
picTop = Int((.ScaleHeight - picHeight) / 2)
End If
End If
' Bild ist kleiner als der Container
Else
' Bild zentrieren?
If bCenter Then
picLeft = Int((.ScaleWidth - picWidth) / 2)
picTop = Int((.ScaleHeight - picHeight) / 2)
End If
End If
' Bild zeichnen
Set .Picture = Nothing
If Not IsMissing(lBackColor) Then .BackColor = lBackColor
.AutoRedraw = True
.PaintPicture pic, picLeft, picTop, picWidth, picHeight
Set .Picture = .Image
.AutoRedraw = False
End With
End Sub Ich habe meine Problemstelle markiert.
Wie ihr seht verlangt er eine .Scale Eigenschaft die meine MDI leider nicht unterstützt
picWidth = .ScaleX(pic.Width, 8, .ScaleMode)
picHeight = .ScaleY(pic.Height, 8, .ScaleMode)
picAspectRatio = picWidth / picHeight Kann mir jemand nen Tipp kriegen wie ich mein Bild im MDI skaliert kriege??
Danke
mfG.
Stephan |