VB Code:
Private Sub DiagGradient(MyForm As Form, rs As Integer, gs As Integer, bs As Integer, re As Integer, ge As Integer, be As Integer, Smooth As Boolean)
Dim ri As Integer
Dim gi As Integer
Dim bi As Integer
Dim rc As Integer
Dim bc As Integer
Dim gc As Integer
Dim x As Integer
If MyForm.WindowState = vbMinimized Then Exit Sub
MyForm.BackColor = RGB(re, ge, be)
If Smooth = True Then
MyForm.DrawStyle = 6
Else
MyForm.DrawStyle = 0
End If
If MyForm.ScaleWidth <> 255 Then
MyForm.ScaleWidth = 255
End If
If MyForm.ScaleHeight <> 255 Then
MyForm.ScaleHeight = 255
End If
MyForm.DrawWidth = 5
MyForm.Refresh
ri = (rs - re) / 255
gi = (gs - ge) / 255
bi = (bs - be) / 255
rc = rs: bc = bs: gc = gs
For x = 0 To 255
DoEvents
MyForm.Line (0, x)-(x, 0), RGB(rc, gc, bc)
rc = rc - ri
gc = gc - gi
bc = bc - bi
Next x
ri = (re - rs) / 255
gi = (ge - gs) / 255
bi = (be - bs) / 255
rc = re: bc = be: gc = ge
For x = 255 To 0 Step -1
DoEvents
MyForm.Line (255 - x, 255)-(255, 255 - x), RGB(rc, gc, bc)
rc = rc - ri
gc = gc - gi
bc = bc - bi
Next x
End Sub
Private Sub Form_Resize()
DiagGradient Form1, 111, 111, 222, 222, 255, 255, True
End Sub