dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Fading Colors

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.
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date