www.pudn.com > 不用API函数实现的窗体颜色渐变.zip > SRC17.FRM, change:2000-06-02,size:1950b


VERSION 5.00 
Begin VB.Form SRC17  
   Appearance      =   0  'Flat 
   BackColor       =   &H80000005& 
   Caption         =   "SRC17" 
   ClientHeight    =   3420 
   ClientLeft      =   1095 
   ClientTop       =   1485 
   ClientWidth     =   6195 
   ForeColor       =   &H80000008& 
   LinkTopic       =   "Form1" 
   PaletteMode     =   1  'UseZOrder 
   ScaleHeight     =   3420 
   ScaleWidth      =   6195 
End 
Attribute VB_Name = "SRC17" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
 
Private Sub Form_Paint() 
    PaintForm Me, 1, 100, 0, 255, 1, 0, -1 
End Sub 
 
Private 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