
Although using the API is a nice way to create multi-colored forms, there might be a reason why you would wish to create one without using the API. To use the example shown below, place the SUB in a module (*.BAS). The routine requires several parameters to be passed to it. They are:
Sub PaintForm (FormName As Form, Orientation%, RStart%, GStart%, BStart%, RInc%, GInc%, BInc%)
' This routine does NOT use API calls
On Error Resume Next
Dim x As Integer, y As Integer, z As Integer, Cycles As Integer
Dim R%, G%, B%
R% = RStart%: G% = GStart%: B% = BStart%
' Dividing the form into 100 equal parts
If Orientation% = 0 Then
Cycles = FormName.ScaleHeight \ 100
Else
Cycles = FormName.ScaleWidth \ 100
End If
For z = 1 To 100
x = x + 1
Select Case Orientation
Case 0: 'Top to Bottom
If x > FormName.ScaleHeight Then Exit For
FormName.Line (0, x)-(FormName.Width, x + Cycles - 1), RGB(R%, G%, B%), BF
Case 1: 'Left to Right
If x > FormName.ScaleWidth Then Exit For
FormName.Line (x, 0)-(x + Cycles - 1, FormName.Height), RGB(R%, G%, B%), BF
End Select
x = x + Cycles
R% = R% + RInc%: G% = G% + GInc%: B% = B% + BInc%
If R% > 255 Then R% = 255
If R% < 0 Then R% = 0
If G% > 255 Then G% = 255
If G% < 0 Then G% = 0
If B% > 255 Then B% = 255
If B% < 0 Then B% = 0
Next z
End Sub
To paint a form call the PaintForm procedure as follows:
PaintForm Me, 1, 100, 0, 255, 1, 0, -1
Experiment with the parameters and see what you can come up with. Keep the values for the incrementing low so as to create a smooth transition, whether they are negative or positive numbers.