vbAccelerator - Contents of code file: fOptions.frm

VERSION 5.00
Begin VB.Form frmOptions 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "BlobSaver Options"
   ClientHeight    =   5685
   ClientLeft      =   6180
   ClientTop       =   1980
   ClientWidth     =   5640
   Icon            =   "fOptions.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5685
   ScaleWidth      =   5640
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdOK 
      Caption         =   "OK"
      Default         =   -1  'True
      Height          =   375
      Left            =   3120
      TabIndex        =   14
      Top             =   5220
      Width           =   1215
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "Cancel"
      Height          =   375
      Left            =   4380
      TabIndex        =   13
      Top             =   5220
      Width           =   1215
   End
   Begin VB.Frame fraSep 
      Height          =   75
      Left            =   -240
      TabIndex        =   6
      Top             =   5040
      Width           =   6675
   End
   Begin BlobSaver.cSlider sldDistribution 
      Height          =   435
      Left            =   900
      TabIndex        =   0
      Top             =   2940
      Width           =   3735
      _ExtentX        =   6800
      _ExtentY        =   767
      Value           =   0
   End
   Begin BlobSaver.cSlider sldIdiocy 
      Height          =   435
      Left            =   900
      TabIndex        =   2
      Top             =   1260
      Width           =   3735
      _ExtentX        =   6588
      _ExtentY        =   767
      Value           =   0
   End
   Begin BlobSaver.cSlider sldBlobs 
      Height          =   435
      Left            =   900
      TabIndex        =   4
      Top             =   4260
      Width           =   3735
      _ExtentX        =   6588
      _ExtentY        =   767
      Max             =   64
   End
   Begin VB.Image imgVBA 
      Height          =   660
      Left            =   150
      Picture         =   "fOptions.frx":030A
      Top             =   90
      Width           =   2535
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      BackColor       =   &H000040C0&
      Caption         =   "Resource "
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   2880
      TabIndex        =   17
      Top             =   435
      Width           =   2535
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H000080FF&
      Caption         =   " The VB Programmer's "
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   2580
      TabIndex        =   16
      Top             =   180
      Width           =   2835
   End
   Begin VB.Label lblAccel 
      BackColor       =   &H00404080&
      BorderStyle     =   1  'Fixed Single
      Height          =   735
      Left            =   120
      TabIndex        =   15
      Top             =   60
      Width           =   5415
   End
   Begin VB.Label lblOutOfIt 
      Alignment       =   2  'Center
      Caption         =   "Out of It"
      Height          =   195
      Left            =   4140
      TabIndex        =   12
      Top             =   1680
      Width           =   735
   End
   Begin VB.Label lblSane 
      Alignment       =   2  'Center
      Caption         =   "Sane"
      Height          =   195
      Left            =   720
      TabIndex        =   11
      Top             =   1680
      Width           =   735
   End
   Begin VB.Label lblPurple 
      Alignment       =   2  'Center
      Caption         =   "Purple"
      Height          =   195
      Left            =   720
      TabIndex        =   10
      Top             =   3360
      Width           =   735
   End
   Begin VB.Label lblGold 
      Alignment       =   2  'Center
      Caption         =   "Goldie"
      Height          =   195
      Left            =   4140
      TabIndex        =   9
      Top             =   3360
      Width           =   735
   End
   Begin VB.Label lblTooMany 
      Alignment       =   2  'Center
      Caption         =   "Too Many"
      Height          =   195
      Left            =   4140
      TabIndex        =   8
      Top             =   4740
      Width           =   735
   End
   Begin VB.Label lblTooFew 
      Alignment       =   2  'Center
      Caption         =   "Too Few"
      Height          =   195
      Left            =   720
      TabIndex        =   7
      Top             =   4740
      Width           =   735
   End
   Begin VB.Label lblBlobCount 
      Caption         =   "Number of Blobs"
      Height          =   255
      Left            =   960
      TabIndex        =   5
      Top             =   3960
      Width           =   3495
   End
   Begin VB.Label lblSilly 
      Caption         =   "Idiocy Frequency"
      Height          =   255
      Left            =   960
      TabIndex        =   3
      Top             =   960
      Width           =   3495
   End
   Begin VB.Label lblDistribution 
      Caption         =   "Distribution:"
      Height          =   255
      Left            =   960
      TabIndex        =   1
      Top             =   2640
      Width           =   3495
   End
End
Attribute VB_Name = "frmOptions"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_cSp(1 To 4) As cSprite
Private m_cStage As cBitmap
Private WithEvents m_tmr As CTimer
Attribute m_tmr.VB_VarHelpID = -1
Private m_bInHere As Boolean

Private Sub cmdCancel_Click()
    pUnloadAnimation
    Unload Me
End Sub

Private Sub cmdOK_Click()
    pUnloadAnimation
    pWriteSettings
    Unload Me
End Sub
Private Sub pWriteSettings()
    Dim cR As New cRegistry
    cR.ClassKey = HKEY_CURRENT_USER
    cR.SectionKey = "Software\vbaccelerator\Blob Saver"
    cR.ValueType = REG_DWORD
    cR.ValueKey = "Idiocy"
    cR.Value = sldIdiocy.Value
    cR.ValueKey = "Proportion"
    cR.Value = sldDistribution.Value
    cR.ValueKey = "Number"
    cR.Value = sldBlobs.Value
End Sub

Private Sub pUnloadAnimation()
Dim iOutLoop As Long
Dim lTIme As Long
Dim i As Long
Dim lHDC As Long

    m_bInHere = False
    For iOutLoop = 1 To m_cSp(1).Width
        lTIme = timeGetTime
        
        ' Restore the stage to its original state:
        For i = 1 To 4
            m_cSp(i).RestoreBackground m_cStage.hDC
        Next i
        
        ' Move & Store backgrounds:
        For i = 1 To 4
            With m_cSp(i)
                If (i = 1) Or (i = 3) Then
                    .x = .x - 1
                Else
                    .x = .x + 1
                End If
                If (i < 3) Then
                    .y = .y + 1
                Else
                    .y = .y - 1
                End If
            End With
            m_cSp(i).StoreBackground m_cStage.hDC, m_cSp(i).x, m_cSp(i).y
        Next i
        
        ' draw new sprite cell:
        For i = 1 To 4
            With m_cSp(i)
                .Cell = .Cell + 1
                If (.Cell > 35) Then
                    .Cell = 1
                End If
                .TransparentDraw m_cStage.hDC, .x, .y, .Cell, False
            End With
        Next i
        
        ' Transfer changes:
        lHDC = Me.hDC
        For i = 1 To 4
            m_cSp(i).StageToScreen lHDC, m_cStage.hDC
        Next i
        
        Do
            DoEvents
        Loop While lTIme + 15 > timeGetTime
    Next iOutLoop
    
End Sub

Private Sub Form_Load()
Dim lW As Long, lH As Long
Dim i As Long
Dim hBr As Long
Dim tR As RECT

    sldIdiocy.Value = g_lIdiocy
    sldDistribution.Value = g_iProportion
    sldBlobs.Value = g_iSpriteNum
    
    For i = 1 To 4
        Set m_cSp(i) = New cSprite
        With m_cSp(i)
            Select Case i
            Case 1
                .SpriteData = g_cSBs
                .x = 0: .y = (lblAccel.Top + lblAccel.Height) \
                 Screen.TwipsPerPixelY
            Case 2
                m_cSp(2).SpriteData = g_cSBA
                .x = Me.ScaleWidth \ Screen.TwipsPerPixelX - .Width: .y =
                 m_cSp(1).y
            Case 3
                m_cSp(3).SpriteData = g_cSBs
                .y = m_cSp(1).y + .Height: .x = 0
            Case 4
                m_cSp(4).SpriteData = g_cSB
                .y = m_cSp(3).y: .x = m_cSp(2).x
            End Select
            .Cell = Rnd * 35
            .Create Me.hDC
        End With
    Next i
    
    Set m_cStage = New cBitmap
    lW = Me.Width \ Screen.TwipsPerPixelX
    lH = Me.Height \ Screen.TwipsPerPixelY
    m_cStage.CreateAtSize lW, lH
    hBr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE))
    tR.Right = lW: tR.Bottom = lH
    FillRect m_cStage.hDC, tR, hBr
    DeleteObject hBr
    
    Me.Show
    
    Set m_tmr = New CTimer
    m_bInHere = True
    m_tmr.Interval = 250
    
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    m_bInHere = False
End Sub

Private Sub m_tmr_ThatTime()
Dim i As Long
Dim lHDC As Long
Dim lTIme As Long
Dim bFirstTime As Boolean
    
    m_tmr.Interval = 0
    Set m_tmr = Nothing
    bFirstTime = True
    
    Do
        lTIme = timeGetTime
        
        ' Restore the stage to its original state:
        For i = 1 To 4
            m_cSp(i).RestoreBackground m_cStage.hDC
        Next i
        
        ' Store backgrounds:
        For i = 1 To 4
            m_cSp(i).StoreBackground m_cStage.hDC, m_cSp(i).x, m_cSp(i).y
        Next i
        
        ' draw new sprite cell:
        For i = 1 To 4
            With m_cSp(i)
                .Cell = .Cell + 1
                If (.Cell > 35) Then
                    .Cell = 1
                End If
                .TransparentDraw m_cStage.hDC, .x, .y, .Cell, False
            End With
        Next i
        
        ' Transfer changes:
        lHDC = Me.hDC
        For i = 1 To 4
            m_cSp(i).StageToScreen lHDC, m_cStage.hDC
        Next i
        
        Do
            DoEvents
        Loop While lTIme + 15 > timeGetTime And m_bInHere
    Loop While (m_bInHere)
    
End Sub

Private Sub sldPercent_Scroll(ByVal lPos As Long)
    Debug.Print lPos
End Sub