home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / create1a / frmanim.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-25  |  5.6 KB  |  164 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   2310
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   2400
  9.    Icon            =   "frmAnim.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   154
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   160
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin VB.VScrollBar vscSpeed 
  18.       Height          =   2055
  19.       LargeChange     =   25
  20.       Left            =   2040
  21.       Max             =   -1
  22.       Min             =   -1000
  23.       TabIndex        =   5
  24.       Top             =   120
  25.       Value           =   -1
  26.       Width           =   255
  27.    End
  28.    Begin VB.CommandButton cmdLoopType 
  29.       Caption         =   "Alternate"
  30.       Height          =   255
  31.       Index           =   2
  32.       Left            =   120
  33.       TabIndex        =   4
  34.       Top             =   1920
  35.       Width           =   1815
  36.    End
  37.    Begin VB.CommandButton cmdLoopType 
  38.       Caption         =   "&Reverse"
  39.       Height          =   255
  40.       Index           =   1
  41.       Left            =   120
  42.       TabIndex        =   3
  43.       Top             =   1680
  44.       Width           =   1815
  45.    End
  46.    Begin VB.CommandButton cmdLoopType 
  47.       Caption         =   "&Forward"
  48.       Height          =   255
  49.       Index           =   0
  50.       Left            =   120
  51.       TabIndex        =   2
  52.       Top             =   1440
  53.       Width           =   1815
  54.    End
  55.    Begin VB.Timer tmrTime 
  56.       Left            =   120
  57.       Top             =   120
  58.    End
  59.    Begin VB.PictureBox picAnim 
  60.       BackColor       =   &H00FFFFFF&
  61.       BorderStyle     =   0  'None
  62.       Height          =   1230
  63.       Left            =   120
  64.       ScaleHeight     =   82
  65.       ScaleMode       =   3  'Pixel
  66.       ScaleWidth      =   120
  67.       TabIndex        =   1
  68.       Top             =   120
  69.       Width           =   1800
  70.    End
  71.    Begin VB.PictureBox picBuffer 
  72.       AutoRedraw      =   -1  'True
  73.       AutoSize        =   -1  'True
  74.       BackColor       =   &H00C0C0FF&
  75.       BorderStyle     =   0  'None
  76.       Height          =   1230
  77.       Left            =   120
  78.       Picture         =   "frmAnim.frx":000C
  79.       ScaleHeight     =   82
  80.       ScaleMode       =   3  'Pixel
  81.       ScaleWidth      =   600
  82.       TabIndex        =   0
  83.       Top             =   2280
  84.       Visible         =   0   'False
  85.       Width           =   9000
  86.    End
  87. Attribute VB_Name = "Form1"
  88. Attribute VB_GlobalNameSpace = False
  89. Attribute VB_Creatable = False
  90. Attribute VB_PredeclaredId = True
  91. Attribute VB_Exposed = False
  92. '----------------------------------------'
  93. 'Title  : Project AnimLogo
  94. 'Author : Timothy Pew
  95. 'E-mail : lord_kirk@geocities.com
  96. 'Copyright 
  97.  1999
  98. '----------------------------------------'
  99. 'This project demonstrates one way to
  100. 'create an animated logo, such as those
  101. 'seen in Netscape Navigator and Microsoft
  102. 'Internet Explorer.
  103. '----------------------------------------'
  104. 'constant values for the direction of animation
  105. Const cFORWARD = 0 'loops to first frame after completing final frame
  106. Const cREVERSE = 1 'loops to final frame after completely first frame
  107. Const cALTERNATE = 2 'reverses the order of animation when it completes the first or last frame
  108. 'variables
  109. Dim LoopType As Integer 'type of animation to perform, uses one of the above constants
  110. Dim Cnt As Integer 'counter variable to keep track of current frame
  111. Dim Dir As Integer 'used to increment/decrement the frame count as needed
  112. Private Sub cmdLoopType_Click(Index As Integer)
  113.     LoopType = Index 'sets the animation type
  114.     If LoopType = cREVERSE Then
  115.         Cnt = 4 'sets the starting frame
  116.         Dir = -1 'count frames backward
  117.     Else
  118.         Cnt = 0 'sets the starting frame
  119.         Dir = 1 'count frames forward
  120.     End If
  121.     'sets the font of button the corrisponds to the LoopType to bold &
  122.     'unbolds the other buttons
  123.     For x = cmdLoopType.LBound To cmdLoopType.ubound
  124.         If x = LoopType Then
  125.             cmdLoopType(x).FontBold = True
  126.         Else
  127.             cmdLoopType(x).FontBold = False
  128.         End If
  129.     Next x
  130.     picAnim.SetFocus 'this is to keep the buttons from having the &
  131.     'focus square for no reason other than that I think it looks sloppy
  132. End Sub
  133. Private Sub Form_Load()
  134.     Show 'avoid an error by making sure that form is displayed
  135.     'set the current loop type to alternate by programmatically clicking
  136.     'the "Alternate" button
  137.     cmdLoopType_Click cALTERNATE
  138.     'set the timer but changing the value of vscSpeed
  139.     'vscSpeed uses negative numbers to make the higher value on top
  140.     vscSpeed.Value = -200
  141. End Sub
  142. Private Sub tmrTime_Timer()
  143.     Cnt = Cnt + Dir 'increment/decrement Cnt as needed
  144.     Select Case LoopType
  145.         Case cFORWARD:
  146.             If Cnt > 4 Then Cnt = 0
  147.             Dir = 1 'makes sure that the direction is correct
  148.         Case cREVERSE:
  149.             If Cnt < 0 Then Cnt = 4
  150.             Dir = -1 'makes sure that the direction is correct
  151.         Case cALTERNATE:
  152.             'swaps direction
  153.             If (Cnt = 4) Or (Cnt = 0) Then Dir = -Dir
  154.     End Select
  155.     'draw the new frame
  156.     BitBlt picAnim.hDC, 0, 0, 120, 82, picBuffer.hDC, Cnt * 120, 0, SRCCOPY
  157. End Sub
  158. Private Sub vscSpeed_Change()
  159.     'set the timer value to the absolute value of vscSpeed
  160.     tmrTime.Interval = Abs(vscSpeed.Value)
  161.     'set the caption to display the current speed
  162.     Caption = "Speed = " & tmrTime.Interval
  163. End Sub
  164.