Re: [2008] MDI form gradient
You need to get a reference to the MdiClient control that is embedded in your parent form and hosts the child forms. You then handle the Paint event of that, rather than the form. The following code uses the improved drawing code that I posted in that last thread of yours. Note the use of the OfType and First extension methods to get the MdiClient reference.
vb.net Code:
Public Class Form1
Private WithEvents client As MdiClient
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As EventArgs) Handles MyBase.Load
Me.client = Me.Controls.OfType(Of MdiClient).First()
End Sub
Private Sub client_Paint(ByVal sender As Object, _
ByVal e As PaintEventArgs) Handles client.Paint
Using Brush As New Drawing2D.LinearGradientBrush(Me.client.Bounds, _
Color.FromArgb(0, 58, 140), _
Color.FromArgb(0, 215, 255), _
Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(Brush, Me.client.Bounds)
End Using
End Sub
End Class
Re: [2008] MDI form gradient
Thanks for the code buddy. I did use it but it has a problem. A small area below the toolbar (if present) or the menubar is not painted. The edge of the form are also not painted (a bit).
Re: [2008] MDI form gradient
The edges are not painted because the MdiClient has a sunken 3D border. You can see that in the designer even with the normal grey colouring for the background, although it's not so obvious with less contrast.
As for the unpainted section below a MenuStrip and/or ToolStrip, that's my fault because I didn't test my code with those items present. Change it to the following and it will handle menus and tool bars:
vb.net Code:
Dim bounds As New Rectangle(Point.Empty, Me.client.Size)
Using Brush As New Drawing2D.LinearGradientBrush(bounds, _
Color.FromArgb(0, 58, 140), _
Color.FromArgb(0, 215, 255), _
Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(Brush, bounds)
End Using
Re: [2008] MDI form gradient
Thanks a lot for the code dude. I appreciate your help.