home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Sudoku_5_12102622192008.psc / Button.ctl < prev    next >
Text File  |  2007-07-20  |  5KB  |  177 lines

  1. VERSION 5.00
  2. Begin VB.UserControl Button 
  3.    AutoRedraw      =   -1  'True
  4.    BackStyle       =   0  'Transparent
  5.    CanGetFocus     =   0   'False
  6.    ClientHeight    =   405
  7.    ClientLeft      =   0
  8.    ClientTop       =   0
  9.    ClientWidth     =   1080
  10.    HasDC           =   0   'False
  11.    MaskColor       =   &H00C0E0FF&
  12.    MaskPicture     =   "Button.ctx":0000
  13.    MouseIcon       =   "Button.ctx":1632
  14.    MousePointer    =   99  'Custom
  15.    Picture         =   "Button.ctx":1784
  16.    ScaleHeight     =   405
  17.    ScaleWidth      =   1080
  18.    ToolboxBitmap   =   "Button.ctx":2DB6
  19.    Begin VB.Timer tmrHiLight 
  20.       Enabled         =   0   'False
  21.       Interval        =   10
  22.       Left            =   360
  23.       Top             =   600
  24.    End
  25.    Begin VB.Image imgLib 
  26.       Height          =   390
  27.       Index           =   2
  28.       Left            =   0
  29.       Picture         =   "Button.ctx":30C8
  30.       Top             =   1740
  31.       Width           =   1080
  32.    End
  33.    Begin VB.Image imgLib 
  34.       Height          =   390
  35.       Index           =   1
  36.       Left            =   0
  37.       Picture         =   "Button.ctx":46FA
  38.       Top             =   1260
  39.       Width           =   1080
  40.    End
  41.    Begin VB.Image imgLib 
  42.       Height          =   390
  43.       Index           =   0
  44.       Left            =   0
  45.       Picture         =   "Button.ctx":5D2C
  46.       Top             =   780
  47.       Width           =   1080
  48.    End
  49.    Begin VB.Label lblCaption 
  50.       Alignment       =   2  'Center
  51.       BackStyle       =   0  'Transparent
  52.       Caption         =   "Caption"
  53.       BeginProperty Font 
  54.          Name            =   "MS Sans Serif"
  55.          Size            =   9.75
  56.          Charset         =   0
  57.          Weight          =   700
  58.          Underline       =   0   'False
  59.          Italic          =   0   'False
  60.          Strikethrough   =   0   'False
  61.       EndProperty
  62.       ForeColor       =   &H00C0C0C0&
  63.       Height          =   240
  64.       Left            =   45
  65.       MouseIcon       =   "Button.ctx":735E
  66.       MousePointer    =   99  'Custom
  67.       TabIndex        =   0
  68.       Top             =   60
  69.       Width           =   1005
  70.    End
  71. End
  72. Attribute VB_Name = "Button"
  73. Attribute VB_GlobalNameSpace = False
  74. Attribute VB_Creatable = True
  75. Attribute VB_PredeclaredId = False
  76. Attribute VB_Exposed = False
  77. Option Explicit
  78. '*********************************
  79. '* Title  : Button               *
  80. '* Type   : ActiveX OCX          *
  81. '* Author : Derio                *
  82. '* Stamp  : 4 July 2007          *
  83. '* Desc   : UI for Sudoku Button *
  84. '*********************************
  85.  
  86. Private MouseOver As Boolean
  87.  
  88. Public Event Click()
  89. Public Event MouseIn()
  90. Public Event MouseOut()
  91.  
  92.  
  93. Private Sub lblCaption_Click()
  94.   If Me.Enabled Then RaiseEvent Click
  95. End Sub
  96.  
  97. Private Sub lblCaption_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  98.   If Me.Enabled Then
  99.     If Not MouseOver Then HiLight
  100.   End If
  101. End Sub
  102.  
  103. Private Sub tmrHiLight_Timer()
  104. Dim Cur As POINT
  105.  
  106.   GetCursorPos Cur
  107.   Cur.X = Cur.X - (Extender.Parent.Left + (Extender.Parent.Width - Extender.Parent.ScaleWidth) / 2) \ Screen.TwipsPerPixelX
  108.   Cur.Y = Cur.Y - (Extender.Parent.Top + Extender.Parent.Height - Extender.Parent.ScaleHeight - 30) \ Screen.TwipsPerPixelY
  109.   
  110.   Cur.X = Cur.X * Screen.TwipsPerPixelX - Extender.Left
  111.   Cur.Y = Cur.Y * Screen.TwipsPerPixelY - Extender.Top
  112.   If Not (Cur.X >= 0 And Cur.X <= UserControl.Width _
  113.           And Cur.Y >= 0 And Cur.Y <= UserControl.Height) Then
  114.     tmrHiLight.Enabled = False
  115.     MouseOver = False
  116.     UserControl.Picture = UserControl.imgLib(1).Picture
  117.     UserControl.lblCaption.ForeColor = RGB(196, 196, 196)
  118.     RaiseEvent MouseOut
  119.   End If
  120. End Sub
  121.  
  122. Private Sub UserControl_Click()
  123.   If Me.Enabled Then RaiseEvent Click
  124. End Sub
  125.  
  126. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  127.   If Me.Enabled Then
  128.     If Not MouseOver Then HiLight
  129.   End If
  130. End Sub
  131.  
  132. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  133.   Me.Caption = PropBag.ReadProperty("Caption", "")
  134.   Me.Enabled = PropBag.ReadProperty("Enabled", True)
  135. End Sub
  136.  
  137. Private Sub UserControl_Resize()
  138.   UserControl.Width = UserControl.imgLib(0).Width
  139.   UserControl.Height = UserControl.imgLib(0).Height
  140. End Sub
  141.  
  142. Public Property Get Caption() As String
  143.   Caption = UserControl.lblCaption
  144. End Property
  145.  
  146. Public Property Let Caption(ByVal vNewValue As String)
  147.   UserControl.lblCaption = vNewValue
  148.   PropertyChanged "Caption"
  149. End Property
  150.  
  151. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  152.   PropBag.WriteProperty "Caption", UserControl.lblCaption.Caption
  153.   PropBag.WriteProperty "Enabled", UserControl.Enabled
  154. End Sub
  155.  
  156. Private Sub HiLight()
  157.   MouseOver = True
  158.   UserControl.Picture = UserControl.imgLib(0)
  159.   UserControl.lblCaption.ForeColor = RGB(255, 255, 255)
  160.   RaiseEvent MouseIn
  161.   If Not tmrHiLight.Enabled Then tmrHiLight.Enabled = True
  162. End Sub
  163.  
  164. Public Property Get Enabled() As Boolean
  165.   Enabled = UserControl.Enabled
  166. End Property
  167.  
  168. Public Property Let Enabled(ByVal vNewValue As Boolean)
  169.   UserControl.Enabled = vNewValue
  170.   If Me.Enabled Then
  171.     UserControl.Picture = UserControl.imgLib(1)
  172.   Else
  173.     UserControl.Picture = UserControl.imgLib(2)
  174.   End If
  175.   PropertyChanged "Enabled"
  176. End Property
  177.