Find all our projects in development below.
All source code is GNU General Public License (GPL)
Browsing Form2.frm (11.22 KB)
VERSION 5.00
Begin VB.Form Form2
BorderStyle = 3 'Fixed Dialog
Caption = "Color Fader"
ClientHeight = 3015
ClientLeft = 45
ClientTop = 330
ClientWidth = 5655
ClipControls = 0 'False
Icon = "Form2.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3015
ScaleWidth = 5655
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command4
Caption = "Cancel"
Height = 375
Left = 120
TabIndex = 10
Top = 2520
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "Fade..."
Default = -1 'True
Height = 375
Left = 4320
TabIndex = 11
Top = 2520
Width = 1215
End
Begin VB.Frame Frame2
Caption = "Color 2"
Height = 2175
Left = 2880
TabIndex = 16
Top = 120
Width = 2655
Begin VB.CheckBox Check2
Caption = "Auto Fade"
Height = 255
Left = 240
TabIndex = 8
Top = 1680
Value = 1 'Checked
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "Random"
Height = 285
Left = 1560
TabIndex = 9
Top = 1680
Width = 855
End
Begin VB.TextBox Text6
Alignment = 2 'Center
Height = 285
Left = 1800
MaxLength = 5
TabIndex = 7
Text = "255"
Top = 600
Width = 615
End
Begin VB.TextBox Text5
Alignment = 2 'Center
Height = 285
Left = 1000
MaxLength = 5
TabIndex = 6
Text = "255"
Top = 600
Width = 615
End
Begin VB.TextBox Text4
Alignment = 2 'Center
Height = 285
Left = 240
MaxLength = 5
TabIndex = 5
Text = "255"
Top = 600
Width = 615
End
Begin VB.Label Label6
Alignment = 2 'Center
Caption = "Blue"
Height = 255
Left = 1770
TabIndex = 19
Top = 360
Width = 615
End
Begin VB.Label Label5
Alignment = 2 'Center
Caption = "Green"
Height = 255
Left = 1000
TabIndex = 18
Top = 360
Width = 615
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "Red"
Height = 255
Left = 240
TabIndex = 17
Top = 360
Width = 615
End
Begin VB.Shape Shape2
FillColor = &H00FFFFFF&
FillStyle = 0 'Solid
Height = 615
Left = 240
Top = 960
Width = 2175
End
End
Begin VB.Frame Frame1
Caption = "Color 1"
Height = 2175
Left = 120
TabIndex = 12
Top = 120
Width = 2655
Begin VB.CheckBox Check1
Caption = "Auto Fade"
Height = 255
Left = 240
TabIndex = 3
Top = 1680
Value = 1 'Checked
Width = 1215
End
Begin VB.TextBox Text1
Alignment = 2 'Center
Height = 285
Left = 240
MaxLength = 5
TabIndex = 0
Text = "0"
Top = 600
Width = 615
End
Begin VB.TextBox Text2
Alignment = 2 'Center
Height = 285
Left = 1000
MaxLength = 5
TabIndex = 1
Text = "0"
Top = 600
Width = 615
End
Begin VB.TextBox Text3
Alignment = 2 'Center
Height = 285
Left = 1770
MaxLength = 5
TabIndex = 2
Text = "0"
Top = 600
Width = 615
End
Begin VB.CommandButton Command1
Caption = "Random"
Height = 285
Left = 1560
TabIndex = 4
Top = 1680
Width = 855
End
Begin VB.Shape Shape1
FillStyle = 0 'Solid
Height = 615
Left = 240
Top = 960
Width = 2175
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Red"
Height = 255
Left = 240
TabIndex = 15
Top = 360
Width = 615
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "Green"
Height = 255
Left = 1000
TabIndex = 14
Top = 360
Width = 615
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "Blue"
Height = 255
Left = 1770
TabIndex = 13
Top = 360
Width = 615
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Randomize Timer
Text1.Text = Int(Rnd * 256)
Text2.Text = Int(Rnd * 256)
Text3.Text = Int(Rnd * 256)
If Check1.Value = 1 Then Command3_Click
End Sub
Private Sub Command2_Click()
Randomize Timer
Text4.Text = Int(Rnd * 256)
Text5.Text = Int(Rnd * 256)
Text6.Text = Int(Rnd * 256)
If Check2.Value = 1 Then Command3_Click
End Sub
Private Sub Command3_Click()
On Error Resume Next
Unload Form3
Form3.Height = Height
Form3.Top = Top
Form3.Left = Left + Width
Form3.Show 0
SetFocus
Form3.DoGradient Form3, Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text), Val(Text5.Text), Val(Text6.Text)
End Sub
Private Sub Command4_Click()
On Error Resume Next
Unload Form3
Unload Me
Form1.Show
End Sub
Private Sub Form_Load()
Text1.Text = Form1.Text7.Text
Text2.Text = Form1.Text8.Text
Text3.Text = Form1.Text9.Text
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = 0 Then
On Error Resume Next
Unload Form3
Form1.Show
End If
End Sub
Private Sub Text1_Change()
Dim R, G, B
R = Val(Text1.Text)
G = Val(Text2.Text)
B = Val(Text3.Text)
If (R >= 0 And G >= 0 And B >= 0) And _
(R <= 255 And G <= 255 And B <= 255) Then
Shape1.FillColor = RGB(R, G, B)
Else
Shape1.FillColor = &H0&
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
KeyAscii = 0
End Sub
Private Sub Text1_LostFocus()
If Text1.Text = "" Or Val(Text1.Text) > 255 Then Text1.Text = "0"
Text1.Text = Trim(Str(Val(Text1.Text)))
End Sub
Private Sub Text2_Change()
Dim R, G, B
R = Val(Text1.Text)
G = Val(Text2.Text)
B = Val(Text3.Text)
If (R >= 0 And G >= 0 And B >= 0) And _
(R <= 255 And G <= 255 And B <= 255) Then
Shape1.FillColor = RGB(R, G, B)
Else
Shape1.FillColor = &H0&
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
KeyAscii = 0
End Sub
Private Sub Text2_LostFocus()
If Text2.Text = "" Or Val(Text2.Text) > 255 Then Text2.Text = "0"
Text2.Text = Trim(Str(Val(Text2.Text)))
End Sub
Private Sub Text3_Change()
Dim R, G, B
R = Val(Text1.Text)
G = Val(Text2.Text)
B = Val(Text3.Text)
If (R >= 0 And G >= 0 And B >= 0) And _
(R <= 255 And G <= 255 And B <= 255) Then
Shape1.FillColor = RGB(R, G, B)
Else
Shape1.FillColor = &H0&
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
KeyAscii = 0
End Sub
Private Sub Text3_LostFocus()
If Text3.Text = "" Or Val(Text3.Text) > 255 Then Text3.Text = "0"
Text3.Text = Trim(Str(Val(Text3.Text)))
End Sub
Private Sub Text4_Change()
Dim R, G, B
R = Val(Text4.Text)
G = Val(Text5.Text)
B = Val(Text6.Text)
If (R >= 0 And G >= 0 And B >= 0) And _
(R <= 255 And G <= 255 And B <= 255) Then
Shape2.FillColor = RGB(R, G, B)
Else
Shape2.FillColor = &H0&
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
KeyAscii = 0
End Sub
Private Sub Text4_LostFocus()
If Text4.Text = "" Or Val(Text4.Text) > 255 Then Text4.Text = "0"
Text4.Text = Trim(Str(Val(Text4.Text)))
End Sub
Private Sub Text5_Change()
Dim R, G, B
R = Val(Text4.Text)
G = Val(Text5.Text)
B = Val(Text6.Text)
If (R >= 0 And G >= 0 And B >= 0) And _
(R <= 255 And G <= 255 And B <= 255) Then
Shape2.FillColor = RGB(R, G, B)
Else
Shape2.FillColor = &H0&
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
KeyAscii = 0
End Sub
Private Sub Text5_LostFocus()
If Text5.Text = "" Or Val(Text5.Text) > 255 Then Text5.Text = "0"
Text5.Text = Trim(Str(Val(Text5.Text)))
End Sub
Private Sub Text6_Change()
Dim R, G, B
R = Val(Text4.Text)
G = Val(Text5.Text)
B = Val(Text6.Text)
If (R >= 0 And G >= 0 And B >= 0) And _
(R <= 255 And G <= 255 And B <= 255) Then
Shape2.FillColor = RGB(R, G, B)
Else
Shape2.FillColor = &H0&
End If
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8 Or KeyAscii = 46 Then Exit Sub
KeyAscii = 0
End Sub
Private Sub Text6_LostFocus()
If Text6.Text = "" Or Val(Text6.Text) > 255 Then Text6.Text = "0"
Text6.Text = Trim(Str(Val(Text6.Text)))
End Sub