Hi!
I have a set of inherited Windows.Forms controls that I have anhanced.
One of those enhancements is the possibility of display a gradient background.
No problem with the painting, the problem is that, for example, on the Label control, the background doesn't refresh if another window passes over it or even if the control is resized...
My painting code is:
Note that:
1- The text is allways well drawn (so the Paint event is called properlly)
2- BackColor2 is a property representing the 2nd gradient color
3- Core.Enums.eFillType.Vertical_AB and all the similar are part of an Enumeration that represents the kind of gradient painting, ie. Vertical_AB represents a vertical gradient from color A to color B.
Thanks!
Alex
I have a set of inherited Windows.Forms controls that I have anhanced.
One of those enhancements is the possibility of display a gradient background.
No problem with the painting, the problem is that, for example, on the Label control, the background doesn't refresh if another window passes over it or even if the control is resized...
My painting code is:
Visual Basic:
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(pevent)
If (Not _BackColor2.IsEmpty) OrElse (Not FillType = Core.Enums.eFillType.OneColor_A) Then
Dim gr1, gr2 As System.Drawing.Drawing2D.LinearGradientBrush
Select Case FillType
Case Core.Enums.eFillType.Vertical_AB
gr1 = New System.Drawing.Drawing2D.LinearGradientBrush( _
New Point(0, 0), New Point(0, pevent.ClipRectangle.Height), _
Me.BackColor, Me.BackColor2)
pevent.Graphics.FillRectangle(gr1, pevent.ClipRectangle)
'Case Core.Enums.eFillType.Vertical_ABA
' ... all other gradient drawing is similar ...
End Select
Else
MyBase.OnPaintBackground(pevent)
End If
End Sub
Note that:
1- The text is allways well drawn (so the Paint event is called properlly)
2- BackColor2 is a property representing the 2nd gradient color
3- Core.Enums.eFillType.Vertical_AB and all the similar are part of an Enumeration that represents the kind of gradient painting, ie. Vertical_AB represents a vertical gradient from color A to color B.
Thanks!
Alex