home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / FlipDigits2080688252007.psc / FlipDigit.ctl < prev    next >
Text File  |  2007-08-15  |  10KB  |  305 lines

  1. VERSION 5.00
  2. Begin VB.UserControl FlipDigit 
  3.    ClientHeight    =   5760
  4.    ClientLeft      =   0
  5.    ClientTop       =   0
  6.    ClientWidth     =   6885
  7.    ScaleHeight     =   5760
  8.    ScaleWidth      =   6885
  9.    Begin VB.PictureBox pic1TO12 
  10.       Appearance      =   0  'Flat
  11.       AutoRedraw      =   -1  'True
  12.       AutoSize        =   -1  'True
  13.       BackColor       =   &H80000005&
  14.       ForeColor       =   &H80000008&
  15.       Height          =   645
  16.       Left            =   135
  17.       Picture         =   "FlipDigit.ctx":0000
  18.       ScaleHeight     =   615
  19.       ScaleWidth      =   21600
  20.       TabIndex        =   4
  21.       Top             =   4935
  22.       Width           =   21630
  23.    End
  24.    Begin VB.PictureBox pic0to5 
  25.       Appearance      =   0  'Flat
  26.       AutoRedraw      =   -1  'True
  27.       AutoSize        =   -1  'True
  28.       BackColor       =   &H80000005&
  29.       ForeColor       =   &H80000008&
  30.       Height          =   645
  31.       Left            =   135
  32.       Picture         =   "FlipDigit.ctx":11CF
  33.       ScaleHeight     =   615
  34.       ScaleWidth      =   10800
  35.       TabIndex        =   3
  36.       Top             =   3450
  37.       Width           =   10830
  38.    End
  39.    Begin VB.PictureBox picBlktoOne 
  40.       Appearance      =   0  'Flat
  41.       AutoRedraw      =   -1  'True
  42.       BackColor       =   &H00404040&
  43.       ForeColor       =   &H80000008&
  44.       Height          =   645
  45.       Left            =   120
  46.       Picture         =   "FlipDigit.ctx":1BA1
  47.       ScaleHeight     =   615
  48.       ScaleWidth      =   3600
  49.       TabIndex        =   2
  50.       Top             =   2715
  51.       Width           =   3630
  52.    End
  53.    Begin VB.Timer Timer1 
  54.       Enabled         =   0   'False
  55.       Interval        =   100
  56.       Left            =   270
  57.       Top             =   2295
  58.    End
  59.    Begin VB.PictureBox picNum 
  60.       Appearance      =   0  'Flat
  61.       AutoRedraw      =   -1  'True
  62.       BackColor       =   &H80000005&
  63.       ForeColor       =   &H80000008&
  64.       Height          =   645
  65.       Left            =   105
  66.       Picture         =   "FlipDigit.ctx":1DF3
  67.       ScaleHeight     =   615
  68.       ScaleWidth      =   18000
  69.       TabIndex        =   1
  70.       Top             =   4185
  71.       Width           =   18030
  72.    End
  73.    Begin VB.PictureBox picDisplay 
  74.       Appearance      =   0  'Flat
  75.       BackColor       =   &H80000005&
  76.       ForeColor       =   &H80000008&
  77.       Height          =   645
  78.       Left            =   0
  79.       ScaleHeight     =   615
  80.       ScaleWidth      =   450
  81.       TabIndex        =   0
  82.       Top             =   0
  83.       Width           =   480
  84.    End
  85. End
  86. Attribute VB_Name = "FlipDigit"
  87. Attribute VB_GlobalNameSpace = False
  88. Attribute VB_Creatable = True
  89. Attribute VB_PredeclaredId = False
  90. Attribute VB_Exposed = False
  91. Option Explicit
  92.  
  93. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  94. Private Const SRCCOPY = &HCC0020
  95.  
  96. Public Enum eMaxNum
  97.     ZeroOne = 0
  98.     ZeroFive = 5
  99.     ZeroNine = 9
  100.     OneTwelve = 12
  101.  End Enum
  102.  
  103. Dim counternum As Long
  104. Dim counter1 As Integer
  105.  
  106. Private Const m_def_Enabled = False
  107. Private Const m_def_MaxNum = 9
  108. Private Const m_def_Speed = 125
  109. Private Const m_def_Value = 0
  110. Private Const m_def_BackColor = &H606060
  111. Private Const m_def_Reset = False
  112. Private Const m_def_StartDigit = 0
  113.  
  114. Dim m_Enabled As Boolean
  115. Dim m_MaxNum As Long
  116. Dim m_Speed As Long
  117. Dim m_Value As Long
  118. Dim m_BackColor As OLE_COLOR
  119. Dim m_Reset As Boolean
  120. Dim m_StartDigit As Long
  121.  
  122. Private Sub UserControl_InitProperties()
  123.    Let Enabled = m_def_Enabled
  124.    Let MaxNum = m_def_MaxNum
  125.    Let Speed = m_def_Speed
  126.    Let Value = m_def_Value
  127.    Let BackColor = m_def_BackColor
  128.    Let Reset = m_def_Reset
  129.    Let StartDigit = m_def_StartDigit
  130. End Sub
  131.  
  132. Private Sub Timer1_Timer()
  133.      If Reset = True Then
  134.         counternum = -1
  135.         If m_MaxNum = 0 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, picBlktoOne.hDC, (1 * 120) + (counter1 * 30), 0, SRCCOPY
  136.         If m_MaxNum = 5 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, pic0to5.hDC, (5 * 120) + (counter1 * 30), 0, SRCCOPY
  137.         If m_MaxNum = 9 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, picNum.hDC, (9 * 120) + (counter1 * 30), 0, SRCCOPY
  138.         If m_MaxNum = 12 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, pic1TO12.hDC, (11 * 120) + (counter1 * 30), 0, SRCCOPY
  139.         If counter1 = 4 Then Reset = False
  140.      End If
  141.      
  142.      If m_MaxNum = 0 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, picBlktoOne.hDC, (counternum * 120) + (counter1 * 30), 0, SRCCOPY
  143.      If m_MaxNum = 5 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, pic0to5.hDC, (counternum * 120) + (counter1 * 30), 0, SRCCOPY
  144.      If m_MaxNum = 9 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, picNum.hDC, (counternum * 120) + (counter1 * 30), 0, SRCCOPY
  145.      If m_MaxNum = 12 Then BitBlt picDisplay.hDC, 0, 0, 30, 41, pic1TO12.hDC, (counternum * 120) + (counter1 * 30), 0, SRCCOPY
  146.    
  147.     counter1 = counter1 + 1
  148.  
  149.     If counter1 > 4 Then
  150.        counternum = counternum + 1      'advance to next whole number
  151.        Timer1.Enabled = False
  152.        counter1 = 1
  153.     End If
  154.  
  155.     ' blank to one
  156.      If m_MaxNum = 0 Then
  157.         If counternum * 120 = 240 Then
  158.            counternum = 0
  159.            BitBlt picDisplay.hDC, 0, 0, 30, 41, picBlktoOne.hDC, counternum, 0, SRCCOPY
  160.        End If
  161.        Value = counternum
  162.      End If
  163.      
  164.      'zero to 5
  165.      If m_MaxNum = 5 Then
  166.         If counternum * 120 = 720 Then
  167.            counternum = 0
  168.            BitBlt picDisplay.hDC, 0, 0, 30, 41, pic0to5.hDC, counternum, 0, SRCCOPY
  169.         End If
  170.         Value = counternum
  171.      End If
  172.      
  173.      'zero to nine
  174.      If m_MaxNum = 9 Then
  175.         If counternum * 120 = 1200 Then
  176.            counternum = 0
  177.            BitBlt picDisplay.hDC, 0, 0, 30, 41, picNum.hDC, counternum, 0, SRCCOPY
  178.       End If
  179.       Value = counternum
  180.       If Value = 10 Then Value = 0
  181.    End If
  182.    
  183.    'one to twelve
  184.      If m_MaxNum = 12 Then
  185.         If counternum * 120 = 1440 Then
  186.            counternum = 0
  187.            BitBlt picDisplay.hDC, 0, 0, 30, 41, pic1TO12.hDC, counternum, 0, SRCCOPY
  188.       End If
  189.       Value = counternum + 1
  190.    End If
  191. End Sub
  192.  
  193. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  194.    With PropBag
  195.       'Let Enabled = .ReadProperty("Enabled", m_def_Enabled)
  196.       Let MaxNum = .ReadProperty("MaxNum", m_def_MaxNum)
  197.       Let Speed = .ReadProperty("Speed", m_def_Speed)
  198.       Let BackColor = .ReadProperty("BackColor", m_def_BackColor)
  199.       Let Reset = .ReadProperty("Reset", m_def_Reset)
  200.       Let StartDigit = .ReadProperty("StartDigit", m_def_StartDigit)
  201.    End With
  202.    Timer1.Enabled = False
  203. End Sub
  204.  
  205. Private Sub UserControl_Resize()
  206.    UserControl.Width = picDisplay.Width
  207.    UserControl.Height = picDisplay.Height
  208. End Sub
  209.  
  210. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  211.    With PropBag
  212.       '.WriteProperty "Enabled", m_Enabled, m_def_Enabled
  213.       .WriteProperty "MaxNum", m_MaxNum, m_def_MaxNum
  214.       .WriteProperty "Speed", m_Speed, m_def_Speed
  215.       .WriteProperty "BackColor", m_BackColor, m_def_BackColor
  216.       .WriteProperty "Reset", m_Reset, m_def_Reset
  217.       .WriteProperty "StartDigit", m_StartDigit, m_def_StartDigit
  218.    End With
  219. End Sub
  220.  
  221. Public Property Get BackColor() As OLE_COLOR
  222.    Let BackColor = m_BackColor
  223. End Property
  224.  
  225. Public Property Let BackColor(ByVal NewBackColor As OLE_COLOR)
  226.    Let m_BackColor = NewBackColor
  227.    picBlktoOne.BackColor = m_BackColor
  228.    pic0to5.BackColor = m_BackColor
  229.    picNum.BackColor = m_BackColor
  230.    pic1TO12.BackColor = m_BackColor
  231.    picDisplay.BackColor = m_BackColor
  232.    PropertyChanged "BackColor"
  233. End Property
  234.  
  235. 'Public Property Get Enabled() As Boolean
  236.  '  Let Enabled = m_Enabled
  237. 'End Property
  238.  
  239. Public Property Let Enabled(ByVal NewEnabled As Boolean)
  240.    Let m_Enabled = NewEnabled
  241.    Timer1.Enabled = m_Enabled
  242.    PropertyChanged "Enabled"
  243. End Property
  244.  
  245. Public Property Get MaxNum() As eMaxNum
  246.    Let MaxNum = m_MaxNum
  247. End Property
  248.  
  249. Public Property Let MaxNum(ByVal NewMaxNum As eMaxNum)
  250.    Let m_MaxNum = NewMaxNum
  251.      If m_MaxNum = 0 Then picDisplay.Picture = picBlktoOne.Picture
  252.      If m_MaxNum = 5 Then picDisplay.Picture = pic0to5.Picture
  253.      If m_MaxNum = 9 Then picDisplay.Picture = picNum.Picture
  254.      If m_MaxNum = 12 Then picDisplay.Picture = pic1TO12.Picture
  255.    PropertyChanged "MaxNum"
  256. End Property
  257.  
  258. Public Property Get StartDigit() As Long
  259.    Let StartDigit = m_StartDigit
  260. End Property
  261.  
  262. Public Property Let StartDigit(ByVal NewStartDigit As Long)
  263.    Let m_StartDigit = NewStartDigit
  264.    If StartDigit <> 0 Then
  265.       If m_MaxNum <> 12 Then counternum = StartDigit - 1
  266.       If m_MaxNum = 12 Then counternum = StartDigit - 2
  267.       Timer1.Enabled = True
  268.    End If
  269.    PropertyChanged "Reset"
  270. End Property
  271.  
  272. Public Property Get Reset() As Boolean
  273.    Let Reset = m_Reset
  274. End Property
  275.  
  276. Public Property Let Reset(ByVal NewReset As Boolean)
  277.    Let m_Reset = NewReset
  278.    Timer1.Enabled = True
  279.    PropertyChanged "Reset"
  280. End Property
  281.  
  282. Public Property Get Speed() As Long
  283.    Let Speed = m_Speed
  284. End Property
  285.  
  286. Public Property Let Speed(ByVal NewSpeed As Long)
  287.    Let m_Speed = NewSpeed
  288.       Timer1.Interval = m_Speed
  289.    PropertyChanged "Speed"
  290. End Property
  291.  
  292. Public Property Get Value() As Long
  293.    Let Value = m_Value
  294. End Property
  295.  
  296. Public Property Let Value(ByVal NewValue As Long)
  297.    Let m_Value = NewValue
  298.    PropertyChanged "Value"
  299. End Property
  300.  
  301. Private Sub UserControl_Terminate()
  302.    Timer1.Enabled = False
  303. End Sub
  304.  
  305.