2011年3月16日 星期三

Me.BackgroundImage resize

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)

If Not Me.BackgroundImage Is Nothing Then
Me.BackgroundImage.Dispose()
Me.BackgroundImage = Nothing
End If
Dim image As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
Dim gr As Graphics = Graphics.FromImage(image)
Dim rect As New Rectangle(New Point(0, 0), Me.ClientSize)

Dim brush As New LinearGradientBrush(rect, _
Color.RosyBrown, ControlPaint.LightLight(Color.RosyBrown), _
LinearGradientMode.Vertical)
brush.SetBlendTriangularShape(0.33)
gr.FillRectangle(brush, rect)
gr.Dispose()

Me.BackgroundImage = image
End Sub

沒有留言:

張貼留言