Draws a gradient from one color to another with Win32 API

Category:
Screen/Graphics
Type:
Snippets
Difficulty:
Intermediate
Author:
Nir Sofer

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
The following code draws a gradient on the entire form, from one color to another. It uses Win32 API in order to get the best performances. The gradient is painted in Form_Paint event. You can change the colors of the gradient by passing different RGB values to PaintGradient function.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: