The GradBackgrounds class is stored inside the gradientobjects.vcx, the class that was published last year that converts any commandbutton, graphical checkbox or graphical optionbox.
Just drop an instance of the class gradbackgrounds to any form, container or pageframe and set some properties to obtain the gradient effects shown below.
All the background images are created using gdi+, but with no helper class, because I wanted to obtain the best performance possible.
gradientmode - numeric, from 1 to 4, determines the gradient type to be created
1 - horizontal 2 - vertical 3 - diagonal 1 4 - diagonal 2 using linear gradient brushes with 2 colors
backcolor1 - numeric, the rgb value of the starting color of the gradient background
backcolor2 - numeric, the rgb value of the destination color of the gradient background
reducecolorlevel - numeric, automatically sets the destination color of the gradient (backcolor2) ranging from 0 (no change) to 100 (white). if left to .f., then no change is applied and the original values of backcolor2 and selbackcolor2 will be used.
updatetabcolor - in the case of a pageframe, sets "themes" off to allow the tab background to be in the same color of the gradient
update - updates the gradient if you change any of the above properties
form using gradientmode = 1
form using gradientmode = 2
form using gradientmode = 3
form using gradientmode = 4
playing with pageframes
As containers, pageframes allow to set a picture property. we can also obtain a cool effect changing the tab colors to use the same color of the gradient picture.
To make it work, drop an instance of the class inside every page thet you want to convert to gradient. when inside a pageframe, the property gradient mode becomes automatic, and works according to the 'tabOrientation' property of the pageframe.
The gradient adapts to the "taborientation" property of the pageframe
To make the class work inside a container, don't forget to set its backstyle to 1 - opaque
Don't forget to set the backstyle property of your labels to 0 - transparent
vfp9 is cool !
In this version of the class I started using some scripts to ease the manipulation of the properties. For example, now if you double click on the backcolor1 property, the color picker opens automatically, to allow you to choose your color. thanks to the great book "what's new in nine", and some great tips from Fabio Lunardon and Tamar Granor.
This class is totally free. The information provided on this page and the source code related to this article comes without any warranty whatsoever. use it at your own risk.
some related links
gradient backgrounds in your forms with gdi+
gradient command buttons with gdi+
gradient objects with gdi+ revisited
click here to download the latest version of the gradient objects class.