Draw Gradients [CODE INSIDE]
Simple to use, short in code and doesnt take much memory when loading. Set your form to AutoRedraw True, then add this code in the Declarations:
VB Code:
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Then add this code:
VB Code:
Public Function gradient(obj As Object, col1, col2)
Dim p As POINTAPI
oldsc = obj.ScaleMode
obj.ScaleMode = 3
r = (col1 And &HFF&)
g = (col1 And &HFF00&) / &H100&
b = (col1 And &HFF0000) / &H10000
r2 = (col2 And &HFF&)
g2 = (col2 And &HFF00&) / &H100&
b2 = (col2 And &HFF0000) / &H10000
sw = obj.ScaleWidth
dr = (r2 - r) / sw
dg = (g2 - g) / sw
db = (b2 - b) / sw
obj.Cls
For i = 1 To sw
r = r + dr
g = g + dg
b = b + db
y = obj.ScaleHeight
obj.ForeColor = RGB(CInt(r), CInt(g), CInt(b))
MoveToEx Form1.hdc, i, 0, p
LineTo obj.hdc, i, y
Next i
obj.ScaleMode = oldsc
End Function
And finally add this:
VB Code:
Private Sub Form_Resize()
gradient Form1, Color1, Color2
End Sub
Enjoy;)