Hi again,
in .net 2003 you have to resize the image your self via code, below is an
example that resizes the image and keeps the correct proportions, it
shouldn't be to hard to modify the code so the image stretches over the
entire form ignorig the proportions. This in fact would be less code then
the sample.
Hope this helps
Greetz, Peter
Private Sub loadimage(ByVal myFileName As String)
Try
Dim imgOrg As Bitmap
Dim imgShow As Bitmap
Dim g As Graphics
Dim delenDoor, delenDoorHO, delenDoorBR As Double
'delenDoor = divide by
'delenDoorHO = divide by height
'delenDoorBR = divide by width
imgOrg = DirectCast(Bitm ap.FromFile(myF ileName), Bitmap)
'Get the forms' dimensions
delenDoorBR = imgOrg.Width / Me.ClientSize.W idth
delenDoorHO = imgOrg.Height / Me.ClientSize.H eight
If delenDoorBR > 1 Or delenDoorHO > 1 Then
If delenDoorBR > delenDoorHO Then
delenDoor = delenDoorBR
Else
delenDoor = delenDoorHO
End If
imgShow = New Bitmap(CInt(CDb l(imgOrg.Width) / delenDoor),
CInt(CDbl(imgOr g.Height) / delenDoor))
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0,
CInt(CDbl(imgOr g.Width) / delenDoor), CInt(CDbl(imgOr g.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pi xel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.W idth, imgOrg.Height)
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pi xel)
g.Dispose()
End If
imgOrg.Dispose( )
Me.BackgroundIm age = imgShow
Me.Refresh()
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
End Sub
Private Sub form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'pass the image file you want to load
loadimage("c:\2 _1024x768.jpg")
End Sub
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)
"mcnewsxp" <mc******@minds pring.com> schreef in bericht
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
how can i set a back ground image property on an MDI main form to stretch?