📄 options.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmOptions
BorderStyle = 3 'Fixed Dialog
Caption = "Life Options"
ClientHeight = 4785
ClientLeft = 45
ClientTop = 330
ClientWidth = 6180
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4785
ScaleWidth = 6180
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdSave
Caption = "Save Settings as Default"
Height = 375
Left = 3330
TabIndex = 0
TabStop = 0 'False
Top = 3420
Width = 2265
End
Begin VB.CommandButton cmdRestore
Caption = "Restore Default Settings"
Height = 375
Left = 585
TabIndex = 1
TabStop = 0 'False
Top = 3420
Width = 2265
End
Begin MSComDlg.CommonDialog ColorDialog1
Left = 4935
Top = 3915
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "Cancel"
Height = 375
Left = 3323
TabIndex = 9
Top = 4140
Width = 1035
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Default = -1 'True
Height = 375
Left = 1845
TabIndex = 8
Top = 4140
Width = 1035
End
Begin VB.Frame Frame1
Height = 2895
Left = 585
TabIndex = 10
Top = 255
Width = 5010
Begin VB.CheckBox cbGridVisible
Caption = "Check1"
Height = 240
Left = 1875
TabIndex = 4
Top = 1965
Width = 255
End
Begin VB.TextBox txtMaxGens
Height = 315
Left = 1890
MaxLength = 4
TabIndex = 2
Top = 945
Width = 675
End
Begin VB.TextBox txtTime
Height = 315
Left = 1875
MaxLength = 5
TabIndex = 3
Top = 1410
Width = 690
End
Begin VB.CommandButton cmdGridColor
Caption = "Grid"
Height = 375
Left = 3135
TabIndex = 7
Top = 1905
Width = 1215
End
Begin VB.CommandButton cmdBGColor
Caption = "Background"
Height = 375
Left = 3135
TabIndex = 6
Top = 1425
Width = 1215
End
Begin VB.CommandButton cmdFGColor
Caption = "Live Cell"
Height = 375
Left = 3135
TabIndex = 5
Top = 945
Width = 1215
End
Begin VB.Shape Shape2
Height = 2040
Left = 2970
Top = 450
Width = 1635
End
Begin VB.Shape Shape1
Height = 2040
Left = 360
Top = 450
Width = 2400
End
Begin VB.Label Label5
Caption = "Behaviour:"
Height = 240
Left = 495
TabIndex = 15
Top = 585
Width = 915
End
Begin VB.Label Label2
Caption = "Grid is visible:"
Height = 225
Left = 810
TabIndex = 14
Top = 1980
Width = 1035
End
Begin VB.Label Label1
Caption = "Max Generations:"
Height = 255
Left = 495
TabIndex = 13
Top = 1005
Width = 1275
End
Begin VB.Label Label3
Caption = "Gen. Time (ms):"
Height = 195
Left = 630
TabIndex = 12
Top = 1470
Width = 1215
End
Begin VB.Shape Rect1
Height = 360
Left = 675
Top = 1905
Visible = 0 'False
Width = 1515
End
Begin VB.Label Label4
Caption = "Colors:"
Height = 195
Left = 3135
TabIndex = 11
Top = 585
Width = 510
End
End
End
Attribute VB_Name = "frmOptions"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim tempMaxGens As Integer
Dim tempInterval As Long
Dim tempCBStatus As Integer
Dim tempAliveCellColor As Long
Dim tempBGColor As Long
Dim tempGridColor As Long
Private Sub cbGridVisible_GotFocus()
Rect1.Visible = True
End Sub
Private Sub cbGridVisible_LostFocus()
Rect1.Visible = False
End Sub
Private Sub cmdBGColor_Click()
' Trap Cancel button pressed.
ColorDialog1.CancelError = True
On Error GoTo ErrHandler
' Set the Flags property.
ColorDialog1.Flags = cdlCCRGBInit
' Display the Color dialog box.
ColorDialog1.ShowColor
' Temorarily store the form's background color to the selected
' color if user pressed OK.
tempBGColor = ColorDialog1.Color
Exit Sub
ErrHandler:
' User pressed Cancel button - make no color changes.
Exit Sub
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdFGColor_Click()
' Trap Cancel button pressed.
ColorDialog1.CancelError = True
On Error GoTo ErrHandler
' Set the Flags property.
ColorDialog1.Flags = cdlCCRGBInit
' Display the Color dialog box.
ColorDialog1.ShowColor
' Temorarily store the Cell's "alive" color to the selected
' color if user pressed OK.
tempAliveCellColor = ColorDialog1.Color
Exit Sub
ErrHandler:
' User pressed Cancel button - make no color changes.
Exit Sub
End Sub
Private Sub cmdGridColor_Click()
' Trap Cancel button pressed.
ColorDialog1.CancelError = True
On Error GoTo ErrHandler
' Set the Flags property.
ColorDialog1.Flags = cdlCCRGBInit
' Display the Color dialog box.
ColorDialog1.ShowColor
' Temorarily store the Grid color to the selected
' color if user pressed OK.
tempGridColor = ColorDialog1.Color
Exit Sub
ErrHandler:
' User pressed Cancel button - make no color changes.
Exit Sub
End Sub
'User pressed OK button on Color Dialog
Private Sub cmdOK_Click()
'Change the settings
g_lAliveCellColor = tempAliveCellColor
g_lFormBGColor = tempBGColor
g_lGridColor = tempGridColor
g_lGridVisible = tempCBStatus
Call ValidateMaxGens
g_lMaxGens = tempMaxGens
Call ValidateInterval
g_lInterval = tempInterval
Unload Me
End Sub
Private Sub cbGridVisible_Click()
If cbGridVisible.Value = vbChecked Then
tempCBStatus = 1
Else
tempCBStatus = 0
End If
End Sub
Private Sub cmdRestore_Click()
Dim result As VbMsgBoxResult
Dim msg As String
'Restore saved settings from the Registry
msg = "Restore default settings?"
result = MsgBox(msg, vbOKCancel)
If result = vbOK Then
Call frmLife.ResetScreen
tempAliveCellColor = g_lAliveCellColor
tempBGColor = g_lFormBGColor
tempGridColor = g_lGridColor
tempCBStatus = g_lGridVisible
txtMaxGens.Text = g_lMaxGens
txtTime.Text = g_lInterval
If g_lGridVisible Then
cbGridVisible.Value = vbChecked
Else
cbGridVisible.Value = vbUnchecked
End If
End If
End Sub
Private Sub cmdSave_Click()
Dim result As VbMsgBoxResult
Dim msg As String
'Validate and Save settings to the Registry
msg = "Save settings as the defaults?"
result = MsgBox(msg, vbOKCancel)
If result = vbOK Then
g_lAliveCellColor = tempAliveCellColor
g_lFormBGColor = tempBGColor
g_lGridColor = tempGridColor
g_lGridVisible = tempCBStatus
Call ValidateMaxGens
g_lMaxGens = tempMaxGens
Call ValidateInterval
g_lInterval = tempInterval
Call SaveSettings
End If
End Sub
Private Sub Form_Load()
tempAliveCellColor = g_lAliveCellColor
tempBGColor = g_lFormBGColor
tempGridColor = g_lGridColor
tempCBStatus = g_lGridVisible
txtMaxGens.Text = g_lMaxGens
txtTime.Text = g_lInterval
If g_lGridVisible Then
cbGridVisible.Value = vbChecked
Else
cbGridVisible.Value = vbUnchecked
End If
End Sub
Private Sub txtMaxGens_GotFocus()
txtMaxGens.SelLength = Len(txtMaxGens.Text)
End Sub
Private Sub txtMaxGens_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = vbBack Then Exit Sub
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtTime_GotFocus()
txtTime.SelLength = Len(txtTime.Text)
End Sub
Private Sub txtTime_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = vbBack Then Exit Sub
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtMaxGens_LostFocus()
Call ValidateMaxGens
End Sub
Private Sub txtTime_LostFocus()
Call ValidateInterval
End Sub
Public Sub ValidateMaxGens()
Dim iNum As Integer
'Process MaxGens text box
If txtMaxGens.Text <> "" Then
iNum = CInt(txtMaxGens.Text)
If iNum = 0 Then
MsgBox "Value must be greater than zero."
txtMaxGens.Text = g_lMaxGens
With txtMaxGens
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
End If
Else
MsgBox "Enter a number greater than zero."
txtMaxGens.Text = g_lMaxGens
With txtMaxGens
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
End If
tempMaxGens = CInt(txtMaxGens.Text)
End Sub
Public Sub ValidateInterval()
Dim iNum As Long
If txtTime.Text <> "" Then
iNum = CLng(txtTime.Text)
If ((iNum < 100) Or (iNum > 65535)) Then
MsgBox "Value must be greater than 99(ms) and less than 65536(ms)."
With txtTime
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
Exit Sub
End With
End If
Else
MsgBox "Enter a number at least 100(ms)."
txtTime.Text = g_lInterval
With txtTime
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
Exit Sub
End With
End If
tempInterval = CLng(txtTime.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -