Use this as a fast way to paint the background of any form with
a really cool "fading" color (lighter at top to darker
at bottom). To specify base color, pass True/False for Red, Green,
and Blue. Use combinations to fade blue, red, green, yellow, purple,
gray, and so on:
Sub FadeForm (frm As Form, Red%, _
Green%, Blue%)
Dim SaveScale%, SaveStyle%, _
SaveRedraw%
Dim i&, j&, x&, y&, pixels%
' Save current settings.
SaveScale = frm.ScaleMode
SaveStyle = frm.DrawStyle
SaveRedraw = frm.AutoRedraw
' Paint screen.
frm.ScaleMode = 3
pixels = Screen.Height / _
Screen.TwipsPerPixelY
x = pixels / 64# + .5
frm.DrawStyle = 5
frm.AutoRedraw = True
For j = 0 To pixels Step x
y = 240 - 245 * j \ pixels
'can tweak this to preference.
If y < 0 Then y = 0
'just in case.
frm.Line (-2, j - 2)- _
(Screen.Width + 2, j + _
x + 3), RGB(-Red * y, -Green _
* y, -Blue * y), BF
Next j
' Reset to previous settings.
frm.ScaleMode = SaveScale
frm.DrawStyle = SaveStyle
frm.AutoRedraw = SaveRedraw
End Sub
For blue fading, just put this in the Form_Load procedure:
FadeForm Me, False, False, True
Timothy L.