home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / FormGradie2080138202007.psc / Form1.frm < prev    next >
Text File  |  2007-08-20  |  25KB  |  757 lines

  1. VERSION 5.00
  2. Begin VB.Form myForm 
  3.    Caption         =   "Form Gradient demo :"
  4.    ClientHeight    =   6855
  5.    ClientLeft      =   60
  6.    ClientTop       =   450
  7.    ClientWidth     =   13305
  8.    Icon            =   "Form1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   6855
  11.    ScaleWidth      =   13305
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.TextBox Text3 
  14.       Alignment       =   2  'Center
  15.       Height          =   375
  16.       Left            =   10800
  17.       TabIndex        =   39
  18.       Text            =   "Text3"
  19.       ToolTipText     =   "VB color (information only)"
  20.       Top             =   6120
  21.       Width           =   1575
  22.    End
  23.    Begin VB.TextBox Text2 
  24.       Alignment       =   2  'Center
  25.       Height          =   375
  26.       Left            =   8640
  27.       TabIndex        =   37
  28.       Text            =   "Text2"
  29.       ToolTipText     =   "VB color (information only)"
  30.       Top             =   6120
  31.       Width           =   1575
  32.    End
  33.    Begin VB.CommandButton Command1 
  34.       Caption         =   "A button"
  35.       Height          =   495
  36.       Left            =   3360
  37.       Style           =   1  'Graphical
  38.       TabIndex        =   35
  39.       Top             =   6000
  40.       Width           =   1455
  41.    End
  42.    Begin VB.OptionButton Option4 
  43.       Caption         =   "Option4 (3)"
  44.       Height          =   375
  45.       Index           =   3
  46.       Left            =   5640
  47.       TabIndex        =   32
  48.       Top             =   4920
  49.       Width           =   1335
  50.    End
  51.    Begin VB.OptionButton Option4 
  52.       Caption         =   "Option4 (2)"
  53.       Height          =   375
  54.       Index           =   2
  55.       Left            =   5640
  56.       TabIndex        =   31
  57.       Top             =   4080
  58.       Width           =   1455
  59.    End
  60.    Begin VB.OptionButton Option4 
  61.       Caption         =   "Option4 (1)"
  62.       Height          =   375
  63.       Index           =   1
  64.       Left            =   5640
  65.       TabIndex        =   30
  66.       Top             =   3240
  67.       Width           =   1335
  68.    End
  69.    Begin VB.OptionButton Option4 
  70.       Caption         =   "Option4 (0)"
  71.       Height          =   375
  72.       Index           =   0
  73.       Left            =   5640
  74.       TabIndex        =   29
  75.       Top             =   2400
  76.       Width           =   1455
  77.    End
  78.    Begin VB.Frame Frame1 
  79.       Caption         =   "A Microsoft frame example"
  80.       Height          =   3375
  81.       Left            =   2640
  82.       TabIndex        =   23
  83.       Top             =   2160
  84.       Width           =   2175
  85.       Begin VB.OptionButton Option3 
  86.          Caption         =   "Option3"
  87.          Height          =   255
  88.          Left            =   600
  89.          TabIndex        =   26
  90.          Top             =   2280
  91.          Width           =   975
  92.       End
  93.       Begin VB.OptionButton Option2 
  94.          Caption         =   "Option2"
  95.          Height          =   255
  96.          Left            =   600
  97.          TabIndex        =   25
  98.          Top             =   1440
  99.          Width           =   975
  100.       End
  101.       Begin VB.CheckBox Check3 
  102.          Caption         =   "Check3"
  103.          Height          =   255
  104.          Left            =   600
  105.          TabIndex        =   24
  106.          Top             =   480
  107.          Width           =   1095
  108.       End
  109.       Begin VB.Label Label13 
  110.          Caption         =   "Here are controls inside a container"
  111.          Height          =   495
  112.          Left            =   120
  113.          TabIndex        =   27
  114.          Top             =   2760
  115.          Width           =   1815
  116.       End
  117.    End
  118.    Begin VB.OptionButton Option1 
  119.       Caption         =   "Another Option button"
  120.       Height          =   375
  121.       Index           =   1
  122.       Left            =   360
  123.       TabIndex        =   22
  124.       Top             =   4920
  125.       Width           =   2295
  126.    End
  127.    Begin VB.OptionButton Option1 
  128.       Caption         =   "An Option button"
  129.       Height          =   375
  130.       Index           =   0
  131.       Left            =   360
  132.       TabIndex        =   21
  133.       Top             =   4080
  134.       Width           =   1815
  135.    End
  136.    Begin VB.CheckBox Check2 
  137.       Caption         =   "Another tick box"
  138.       Height          =   375
  139.       Left            =   360
  140.       TabIndex        =   20
  141.       Top             =   3240
  142.       Width           =   1575
  143.    End
  144.    Begin VB.CheckBox Check1 
  145.       Caption         =   "A tick box"
  146.       Height          =   375
  147.       Left            =   360
  148.       TabIndex        =   19
  149.       Top             =   2400
  150.       Width           =   1215
  151.    End
  152.    Begin VB.TextBox Text1 
  153.       Alignment       =   2  'Center
  154.       BeginProperty Font 
  155.          Name            =   "MS Sans Serif"
  156.          Size            =   9.75
  157.          Charset         =   0
  158.          Weight          =   400
  159.          Underline       =   0   'False
  160.          Italic          =   0   'False
  161.          Strikethrough   =   0   'False
  162.       EndProperty
  163.       Height          =   375
  164.       Left            =   8040
  165.       TabIndex        =   14
  166.       Text            =   "Text1"
  167.       Top             =   5160
  168.       Width           =   4935
  169.    End
  170.    Begin VB.VScrollBar BF 
  171.       Height          =   3615
  172.       LargeChange     =   50
  173.       Left            =   12000
  174.       Max             =   1020
  175.       Min             =   4
  176.       SmallChange     =   10
  177.       TabIndex        =   5
  178.       Top             =   960
  179.       Value           =   225
  180.       Width           =   375
  181.    End
  182.    Begin VB.VScrollBar GF 
  183.       Height          =   3615
  184.       LargeChange     =   50
  185.       Left            =   11400
  186.       Max             =   1020
  187.       Min             =   4
  188.       SmallChange     =   10
  189.       TabIndex        =   4
  190.       Top             =   960
  191.       Value           =   384
  192.       Width           =   375
  193.    End
  194.    Begin VB.VScrollBar RF 
  195.       Height          =   3615
  196.       LargeChange     =   50
  197.       Left            =   10800
  198.       Max             =   1020
  199.       Min             =   4
  200.       SmallChange     =   10
  201.       TabIndex        =   3
  202.       Top             =   960
  203.       Value           =   612
  204.       Width           =   375
  205.    End
  206.    Begin VB.VScrollBar BS 
  207.       Height          =   3615
  208.       LargeChange     =   50
  209.       Left            =   9840
  210.       Max             =   1020
  211.       Min             =   4
  212.       SmallChange     =   10
  213.       TabIndex        =   2
  214.       Top             =   960
  215.       Value           =   4
  216.       Width           =   375
  217.    End
  218.    Begin VB.VScrollBar GS 
  219.       Height          =   3615
  220.       LargeChange     =   50
  221.       Left            =   9240
  222.       Max             =   1020
  223.       Min             =   4
  224.       SmallChange     =   10
  225.       TabIndex        =   1
  226.       Top             =   960
  227.       Value           =   44
  228.       Width           =   375
  229.    End
  230.    Begin VB.VScrollBar RS 
  231.       Height          =   3615
  232.       LargeChange     =   50
  233.       Left            =   8640
  234.       Max             =   1020
  235.       Min             =   4
  236.       SmallChange     =   10
  237.       TabIndex        =   0
  238.       Top             =   960
  239.       Value           =   82
  240.       Width           =   375
  241.    End
  242.    Begin VB.Line Line4 
  243.       BorderWidth     =   3
  244.       X1              =   0
  245.       X2              =   7680
  246.       Y1              =   6840
  247.       Y2              =   6840
  248.    End
  249.    Begin VB.Label Label20 
  250.       Height          =   255
  251.       Left            =   4920
  252.       TabIndex        =   41
  253.       Top             =   6120
  254.       Width           =   1695
  255.    End
  256.    Begin VB.Label Label17 
  257.       Alignment       =   1  'Right Justify
  258.       Caption         =   "Click this to change Button color after the FormGradient subroutine has run."
  259.       Height          =   495
  260.       Left            =   360
  261.       TabIndex        =   40
  262.       Top             =   6000
  263.       Width           =   2895
  264.    End
  265.    Begin VB.Label Label19 
  266.       Caption         =   "Finish color"
  267.       Height          =   255
  268.       Left            =   10800
  269.       TabIndex        =   38
  270.       Top             =   5880
  271.       Width           =   975
  272.    End
  273.    Begin VB.Label Label18 
  274.       Caption         =   "Start color"
  275.       Height          =   255
  276.       Left            =   8640
  277.       TabIndex        =   36
  278.       Top             =   5880
  279.       Width           =   855
  280.    End
  281.    Begin VB.Label Label16 
  282.       Alignment       =   2  'Center
  283.       Caption         =   "Image (no picture)"
  284.       Height          =   255
  285.       Left            =   5400
  286.       TabIndex        =   34
  287.       Top             =   2040
  288.       Width           =   1455
  289.    End
  290.    Begin VB.Image Image1 
  291.       BorderStyle     =   1  'Fixed Single
  292.       Height          =   3255
  293.       Left            =   5280
  294.       Top             =   2280
  295.       Width           =   1935
  296.    End
  297.    Begin VB.Label Label15 
  298.       Alignment       =   2  'Center
  299.       Caption         =   "See Notes.txt"
  300.       BeginProperty Font 
  301.          Name            =   "MS Sans Serif"
  302.          Size            =   9.75
  303.          Charset         =   0
  304.          Weight          =   400
  305.          Underline       =   0   'False
  306.          Italic          =   0   'False
  307.          Strikethrough   =   0   'False
  308.       EndProperty
  309.       ForeColor       =   &H000000FF&
  310.       Height          =   255
  311.       Left            =   6480
  312.       TabIndex        =   33
  313.       Top             =   480
  314.       Width           =   1815
  315.    End
  316.    Begin VB.Line Line3 
  317.       BorderWidth     =   3
  318.       X1              =   0
  319.       X2              =   7680
  320.       Y1              =   5760
  321.       Y2              =   5760
  322.    End
  323.    Begin VB.Label Label14 
  324.       Caption         =   "Paste this into your  Form_Load subroutine"
  325.       Height          =   255
  326.       Left            =   8160
  327.       TabIndex        =   28
  328.       Top             =   4920
  329.       Width           =   3255
  330.    End
  331.    Begin VB.Line Line2 
  332.       BorderWidth     =   3
  333.       X1              =   7680
  334.       X2              =   7680
  335.       Y1              =   1440
  336.       Y2              =   6840
  337.    End
  338.    Begin VB.Line Line1 
  339.       BorderWidth     =   3
  340.       X1              =   0
  341.       X2              =   7680
  342.       Y1              =   1440
  343.       Y2              =   1440
  344.    End
  345.    Begin VB.Label Label12 
  346.       Caption         =   "The labels and controls inside here do not do anything."
  347.       BeginProperty Font 
  348.          Name            =   "MS Sans Serif"
  349.          Size            =   9.75
  350.          Charset         =   0
  351.          Weight          =   400
  352.          Underline       =   0   'False
  353.          Italic          =   0   'False
  354.          Strikethrough   =   0   'False
  355.       EndProperty
  356.       Height          =   375
  357.       Left            =   120
  358.       TabIndex        =   18
  359.       Top             =   1680
  360.       Width           =   5415
  361.    End
  362.    Begin VB.Label Label11 
  363.       Caption         =   "The text can be pasted directly into your Form_Load subroutine."
  364.       BeginProperty Font 
  365.          Name            =   "MS Sans Serif"
  366.          Size            =   9.75
  367.          Charset         =   0
  368.          Weight          =   400
  369.          Underline       =   0   'False
  370.          Italic          =   0   'False
  371.          Strikethrough   =   0   'False
  372.       EndProperty
  373.       Height          =   375
  374.       Left            =   360
  375.       TabIndex        =   17
  376.       Top             =   960
  377.       Width           =   6015
  378.    End
  379.    Begin VB.Label Label10 
  380.       Caption         =   "The sliders can be used to try color schemes."
  381.       BeginProperty Font 
  382.          Name            =   "MS Sans Serif"
  383.          Size            =   9.75
  384.          Charset         =   0
  385.          Weight          =   400
  386.          Underline       =   0   'False
  387.          Italic          =   0   'False
  388.          Strikethrough   =   0   'False
  389.       EndProperty
  390.       Height          =   375
  391.       Left            =   360
  392.       TabIndex        =   16
  393.       Top             =   600
  394.       Width           =   5055
  395.    End
  396.    Begin VB.Label Label9 
  397.       Caption         =   "This is a demonstration of the subroutine  FormGradient."
  398.       BeginProperty Font 
  399.          Name            =   "MS Sans Serif"
  400.          Size            =   9.75
  401.          Charset         =   0
  402.          Weight          =   700
  403.          Underline       =   0   'False
  404.          Italic          =   0   'False
  405.          Strikethrough   =   0   'False
  406.       EndProperty
  407.       Height          =   375
  408.       Left            =   240
  409.       TabIndex        =   15
  410.       Top             =   120
  411.       Width           =   6135
  412.    End
  413.    Begin VB.Label Label8 
  414.       Alignment       =   2  'Center
  415.       Caption         =   "Finish"
  416.       BeginProperty Font 
  417.          Name            =   "MS Sans Serif"
  418.          Size            =   12
  419.          Charset         =   0
  420.          Weight          =   700
  421.          Underline       =   0   'False
  422.          Italic          =   0   'False
  423.          Strikethrough   =   0   'False
  424.       EndProperty
  425.       Height          =   375
  426.       Left            =   11040
  427.       TabIndex        =   13
  428.       Top             =   240
  429.       Width           =   855
  430.    End
  431.    Begin VB.Label Label7 
  432.       Alignment       =   2  'Center
  433.       Caption         =   "Start"
  434.       BeginProperty Font 
  435.          Name            =   "MS Sans Serif"
  436.          Size            =   12
  437.          Charset         =   0
  438.          Weight          =   700
  439.          Underline       =   0   'False
  440.          Italic          =   0   'False
  441.          Strikethrough   =   0   'False
  442.       EndProperty
  443.       Height          =   375
  444.       Left            =   9000
  445.       TabIndex        =   12
  446.       Top             =   240
  447.       Width           =   855
  448.    End
  449.    Begin VB.Label Label6 
  450.       Alignment       =   2  'Center
  451.       Caption         =   "B"
  452.       BeginProperty Font 
  453.          Name            =   "MS Sans Serif"
  454.          Size            =   12
  455.          Charset         =   0
  456.          Weight          =   700
  457.          Underline       =   0   'False
  458.          Italic          =   0   'False
  459.          Strikethrough   =   0   'False
  460.       EndProperty
  461.       Height          =   255
  462.       Left            =   12000
  463.       TabIndex        =   11
  464.       Top             =   600
  465.       Width           =   375
  466.    End
  467.    Begin VB.Label Label5 
  468.       Alignment       =   2  'Center
  469.       Caption         =   "B"
  470.       BeginProperty Font 
  471.          Name            =   "MS Sans Serif"
  472.          Size            =   12
  473.          Charset         =   0
  474.          Weight          =   700
  475.          Underline       =   0   'False
  476.          Italic          =   0   'False
  477.          Strikethrough   =   0   'False
  478.       EndProperty
  479.       Height          =   255
  480.       Left            =   9840
  481.       TabIndex        =   10
  482.       Top             =   600
  483.       Width           =   375
  484.    End
  485.    Begin VB.Label Label4 
  486.       Alignment       =   2  'Center
  487.       Caption         =   "G"
  488.       BeginProperty Font 
  489.          Name            =   "MS Sans Serif"
  490.          Size            =   12
  491.          Charset         =   0
  492.          Weight          =   700
  493.          Underline       =   0   'False
  494.          Italic          =   0   'False
  495.          Strikethrough   =   0   'False
  496.       EndProperty
  497.       Height          =   255
  498.       Left            =   11400
  499.       TabIndex        =   9
  500.       Top             =   600
  501.       Width           =   375
  502.    End
  503.    Begin VB.Label Label3 
  504.       Alignment       =   2  'Center
  505.       Caption         =   "G"
  506.       BeginProperty Font 
  507.          Name            =   "MS Sans Serif"
  508.          Size            =   12
  509.          Charset         =   0
  510.          Weight          =   700
  511.          Underline       =   0   'False
  512.          Italic          =   0   'False
  513.          Strikethrough   =   0   'False
  514.       EndProperty
  515.       Height          =   255
  516.       Left            =   9240
  517.       TabIndex        =   8
  518.       Top             =   600
  519.       Width           =   375
  520.    End
  521.    Begin VB.Label Label2 
  522.       Alignment       =   2  'Center
  523.       Caption         =   "R"
  524.       BeginProperty Font 
  525.          Name            =   "MS Sans Serif"
  526.          Size            =   12
  527.          Charset         =   0
  528.          Weight          =   700
  529.          Underline       =   0   'False
  530.          Italic          =   0   'False
  531.          Strikethrough   =   0   'False
  532.       EndProperty
  533.       Height          =   255
  534.       Left            =   10800
  535.       TabIndex        =   7
  536.       Top             =   600
  537.       Width           =   375
  538.    End
  539.    Begin VB.Label Label1 
  540.       Alignment       =   2  'Center
  541.       Caption         =   "R"
  542.       BeginProperty Font 
  543.          Name            =   "MS Sans Serif"
  544.          Size            =   12
  545.          Charset         =   0
  546.          Weight          =   700
  547.          Underline       =   0   'False
  548.          Italic          =   0   'False
  549.          Strikethrough   =   0   'False
  550.       EndProperty
  551.       Height          =   255
  552.       Left            =   8640
  553.       TabIndex        =   6
  554.       Top             =   600
  555.       Width           =   375
  556.    End
  557. End
  558. Attribute VB_Name = "myForm"
  559. Attribute VB_GlobalNameSpace = False
  560. Attribute VB_Creatable = False
  561. Attribute VB_PredeclaredId = True
  562. Attribute VB_Exposed = False
  563. Option Explicit
  564. '-------------------  For demo only -------------------.
  565. Dim DemoColor%                                        '|
  566. Dim Rstart%, Gstart%, Bstart%, Rend%, Gend%, Bend%    '|
  567. '------------------------------------------------------'
  568.  
  569.  
  570. 'Call FormGradient from Form_Load
  571. Private Sub Form_Load()
  572.    FormGradient Me, 236, 245, 256, 128, 158, 182                           'Use your own variables
  573.    Text1.Text = "FormGradient Me, 236, 245, 256, 128, 158, 182"            '** For this demo only
  574. End Sub
  575.  
  576. 'If you allow form resizing then call FormGradient again
  577. Private Sub Form_Resize()
  578.    'FormGradient Me, 236, 245, 256, 128, 158, 182        '<-- Use your own variables
  579.    
  580.    Redraw   '** For this demo only
  581. End Sub
  582.  
  583. '-------------------------------------------------------------------------------------------------------------
  584. 'Purpose    Set Form and conrol backgound to a vertical color gradient
  585. 'Inputs     Form, RGB start color, RGB end color + automatic -> Form ScaleHeight at time of Form_Load
  586. 'Notes      Auto-set Label BackStyle to 0 - Transparent
  587. '           Auto-set CheckBoxes.BackColor, OptionBoxes.Backcolor, etc to the Form color at their position
  588. 'usage      In Form_Load subroutines call  FormGradient Me, 174, 212, 255, 124, 152, 225
  589. '           Add the subroutine FormGradient to your form code module or better still to a general code module
  590. '           If you want to change the colors at runtime, then call FormGradient again with new parameters
  591. '           If you allow form resizing then call FormGradient in the Form_Resize subroutine
  592. 'Author     Mike Wardle
  593. '-------------------------------------------------------------------------------------------------------------
  594. Public Sub FormGradient(TheForm As Form, RedStart%, GreenStart%, BlueStart%, RedEnd%, GreenEnd%, BlueEnd%)
  595.    Dim i%, j%, Y!, H%
  596.    Dim Rk!, Gk!, Bk!          'Color steps
  597.    Dim R%, G%, b%             'Colors
  598.    Dim Params() As Variant    'Array for required parameters
  599.    Dim ctlObj As Control
  600.    Dim ContObj As Control
  601.    Dim yScale!                'Scaling used inside containers
  602.  
  603.    Rk = (RedStart% - RedEnd%) / 1024
  604.    Gk = (GreenStart% - GreenEnd%) / 1024
  605.    Bk = (BlueStart% - BlueEnd%) / 1024
  606.  
  607.    On Error Resume Next
  608.  
  609.    With TheForm
  610.       .AutoRedraw = True
  611.       .DrawStyle = vbInsideSolid
  612.       .DrawMode = vbCopyPen
  613.       .ScaleMode = vbPixels
  614.       .DrawWidth = 2
  615.       .ScaleHeight = 1024
  616.    End With
  617.  
  618.    For Y! = 0 To 1023
  619.       j% = Y!
  620.       R% = RedStart% - j% * Rk: G% = GreenStart% - j% * Gk: b% = BlueStart% - j% * Bk
  621.       TheForm.Line (0, Y!)-(Screen.Width, Y! - 1), RGB(R%, G%, b%), B
  622.    Next
  623.  
  624.    'Using this array allows the Formgradient to deal with controls inside containers
  625.    i% = 0
  626.    ReDim Params(TheForm.Count, 5)
  627.    For Each ctlObj In TheForm
  628.       Params(i%, 0) = LCase(TypeName(ctlObj))                     'Object Type
  629.       Params(i%, 1) = LCase(ctlObj.Name)                          'Object name
  630.       Params(i%, 2) = LCase(ctlObj.Container.Name)                'Container name
  631.       Params(i%, 3) = CInt(ctlObj.Top)                            'Top value
  632.       Params(i%, 4) = CInt(ctlObj.Height)                         'Height value
  633.  
  634.       'Set all Label BackStyles to Transparent
  635.       If Params(i%, 0) = LCase("Label") Then      'Set Property
  636.          ctlObj.BackStyle = 0
  637.       Else
  638.          Y! = Params(i%, 3)
  639.          H% = Params(i%, 4)
  640.          Y! = Y! + H% / 2
  641.          If Params(i%, 2) = LCase(TheForm.Name) Then
  642.             Params(i%, 5) = Y!
  643.          End If
  644.       End If
  645.       i% = i% + 1
  646.    Next
  647.  
  648.    'At this point all required controls will have a y-value in Params( ,5)
  649.    'Now fix the colors for the controls that are inside a container
  650.    i% = 0
  651.    For Each ctlObj In TheForm       'Loop through all controls in the form again
  652.  
  653.       If Params(i%, 1) <> LCase(TheForm.Name) Then                      'Inside a container
  654.          'Set mean y-value
  655.          yScale = TheForm.ScaleHeight / TheForm.Height
  656.          For j% = 0 To TheForm.Count
  657.             If (j% <> i%) And (Params(j%, 1) = Params(i%, 2)) Then   'This is the container
  658.                Params(i%, 5) = Params(j%, 5)                         'Set y same as container
  659.                j% = TheForm.Count
  660.             End If
  661.          Next j%
  662.       End If
  663.       i% = i% + 1
  664.    Next
  665.  
  666.    'Finally set the control background colors
  667.    i% = 0
  668.    For Each ctlObj In TheForm
  669.       If Params(i%, 5) > 0 Then
  670.          Y! = Params(i%, 5)
  671.          j% = Y!
  672.          R% = RedStart% - j% * Rk: G% = GreenStart% - j% * Gk: b% = BlueStart% - j% * Bk
  673.          ctlObj.BackColor = RGB(R%, G%, b%)
  674.       End If
  675.       i% = i% + 1
  676.    Next
  677.    On Error GoTo 0
  678. End Sub
  679.  
  680.  
  681. '********************************************************************************
  682. '***                          Below here is Demo only                         ***
  683. '********************************************************************************
  684.  
  685. Private Sub Redraw()
  686.    Rstart = 256 - RS.Value / 4
  687.    Gstart = 256 - GS.Value / 4
  688.    Bstart = 256 - BS.Value / 4
  689.    Rend = 256 - RF.Value / 4
  690.    Gend = 256 - GF.Value / 4
  691.    Bend = 256 - BF.Value / 4
  692.    FormGradient Me, Rstart, Gstart, Bstart, Rend, Gend, Bend
  693.    Text1.Text = "FormGradient Me," & Str(Rstart) & "," & Str(Gstart) & "," & Str(Bstart) & "," & Str(Rend) & "," & Str(Gend) & "," & Str(Bend)
  694.    
  695.    'For information - Like a color picker
  696.    Text2.Text = GetVBColor(Rstart, Gstart, Bstart)
  697.    Text3.Text = GetVBColor(Rend, Gend, Bend)
  698. End Sub
  699.  
  700. Private Sub RS_Change()
  701.    Redraw
  702. End Sub
  703.  
  704. Private Sub GS_Change()
  705.    Redraw
  706. End Sub
  707.  
  708. Private Sub BS_Change()
  709.    Redraw
  710. End Sub
  711.  
  712. Private Sub RF_Change()
  713.    Redraw
  714. End Sub
  715.  
  716. Private Sub GF_Change()
  717.    Redraw
  718. End Sub
  719.  
  720. Private Sub BF_Change()
  721.    Redraw
  722. End Sub
  723.  
  724. Private Function GetVBColor(RVal, GVal, BVal) As String
  725.    Dim Rhex As String
  726.    Dim Ghex As String
  727.    Dim Bhex As String
  728.    Dim H$
  729.    
  730.     Rhex = Hex(RVal)
  731.     If Len(CStr(Rhex)) < 2 Then Rhex = "0" & Rhex
  732.     Ghex = Hex(GVal)
  733.     If Len(CStr(Ghex)) < 2 Then Ghex = "0" & Ghex
  734.     Bhex = Hex(BVal)
  735.     If Len(CStr(Bhex)) < 2 Then Bhex = "0" & Bhex
  736.     H$ = Chr(38) & "H" & Bhex & Ghex & Rhex & Chr(38)
  737.     GetVBColor = H$
  738. End Function
  739.  
  740. Private Sub Command1_Click()
  741.    Dim Bakcolor As Long
  742.    
  743.    DemoColor = DemoColor + 1
  744.    If DemoColor > 3 Then DemoColor = 0
  745.    Select Case DemoColor
  746.       Case 0: Bakcolor = &H8000000F
  747.       Case 1: Bakcolor = (&H10000 * Bstart) + (&H100& * Gstart) + Rstart
  748.       Case 2: Bakcolor = ((&H10000 * Bstart) + (&H100& * Gstart)) / 2 + (Rstart + (&H10000 * Bend) + (&H100& * Gend) + Rend) / 2
  749.       Case 3: Bakcolor = (&H10000 * Bend) + (&H100& * Gend) + Rend
  750.    End Select
  751.    Command1.BackColor = Bakcolor
  752.    Label20.Caption = Hex(Command1.BackColor)
  753. End Sub
  754.  
  755. '**************************************************
  756.  
  757.