Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #76
Online Version at http://www.codeoftheweek.com/membersonly/bi/0076.html (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Cool Software

Download a free copy of NetMon - Your Internet Performance Monitor at http://www.codeoftheweek.com/netmon/index.html

Special Deal

Get a LIFETIME subscription to Code of the Week for only $49.95 (regularly $59.95). Just jump to our SECRET order page at http://www.codeoftheweek.com/orderforms/lifetime4995.html and see everything you get with this outstanding offer!

In this Issue

In this issue we show how to add a gradient color background to your forms.

This source code is designed for VB 4.0 32-bit and up. Questions? Email us at questions@codeoftheweek.com.

basFormEffects

The basFormEffects module contains a routine to paint a gradient background on any form. It is designed to work with any form.

If you have any questions about using or creating this control, let us know at questions@codeoftheweek.com

Subroutine

Public Sub GradientFill(Obj As Form, lTopColor As Long, lBottomColor As Long)

This subroutine does all the work. It will start with the lTopColor and paint a gradient to lBottomColor on the form specified by Obj. The most common place you see this type of background is in setup programs. They usually have a faded blue to black background. This routine will allow you to specify any of the built-in constants for the colors that VB defines (vbBlack, vbRed, vbGreen, vbYellow, vbBlue, vbMagenta, vbCyan, vbWhite).

Returns

Raises an error if any of the internal calls fail. There is no particular error that will be raised.

Sample Usage

The below sample describes how to use the GradientFill routine. It assumes you have created a form and added the following code to it. Make sure the AutoRedraw property is False for this sample.

Private Sub Form_Load()
    Me.Show
End Sub

Private Sub Form_Paint()
    GradientFill Me, vbRed, vbWhite
End Sub

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0076.html


This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com