By Ken Huysmans on
2004-11-25T11:02:00
If you have a picture as background of your MDI, that picture is not resized when you resize your form. There seems no easy way (like a property) to accomplish this.
So I wrote a little piece of code that will create a new image starting from the original background image, but with the dimensions of the main form.
Declare a global variable for your form:
Private myBackground As Image
Add this code to the Resize-event of your form:
If myBackground Is Nothing Then
myBackground = Me.BackgroundImage
End If
If Me.ClientSize.Width = 0 Then Exit Sub 'Remark1
Dim bmp As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height, Imaging.PixelFormat.Format24bppRgb) 'Remark2
Dim gr As Graphics = Graphics.FromImage(bmp)
gr.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
gr.DrawImage(myBackground, 0, 0, bmp.Width, bmp.Height)
Me.BackgroundImage = bmp
If you have a statusbar (called myStatus in this example) on the bottom of your form, alter the line marked with 'Remark1...
Read More »