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

  1. VERSION 5.00
  2. Begin VB.UserControl button 
  3.    BackColor       =   &H00E0E0E0&
  4.    ClientHeight    =   420
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   1260
  8.    ScaleHeight     =   420
  9.    ScaleWidth      =   1260
  10.    Begin VB.Label Label1 
  11.       AutoSize        =   -1  'True
  12.       BackStyle       =   0  'Transparent
  13.       Caption         =   "Label1"
  14.       BeginProperty Font 
  15.          Name            =   "Tahoma"
  16.          Size            =   9.75
  17.          Charset         =   0
  18.          Weight          =   700
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   240
  24.       Left            =   240
  25.       TabIndex        =   0
  26.       Top             =   120
  27.       Width           =   630
  28.    End
  29. End
  30. Attribute VB_Name = "button"
  31. Attribute VB_GlobalNameSpace = False
  32. Attribute VB_Creatable = True
  33. Attribute VB_PredeclaredId = False
  34. Attribute VB_Exposed = False
  35. Option Explicit ':(áLine inserted by Formatter
  36. Public Event Click()
  37. Public Event Mouseup()
  38. Private Enab As Boolean ':(áMissing Scope
  39. Private Skinned As Boolean
  40. Public Property Get Caption() As String
  41.     Caption = Label1.Caption
  42. End Property
  43. Public Property Let Caption(Text As String)
  44.     Label1.Caption = Text
  45.     Label1.Left = (UserControl.Width - Label1.Width) / 2
  46.     Label1.Top = (UserControl.Height - Label1.Height) / 2
  47.     ReDraw False
  48. End Property
  49. Public Property Let FontSize(Size As Long)
  50.     Label1.FontSize = Size
  51. End Property
  52. Public Property Let FontColor(Color As Long)
  53.     Label1.ForeColor = Color
  54. End Property
  55. Public Property Let Backcolor(Color As Long)
  56.     UserControl.Backcolor = Color
  57. End Property
  58. Public Property Let Enabled(En As Boolean)
  59.     Enab = En
  60. End Property
  61. Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  62.     UserControl_MouseDown 1, 0, 0, 0
  63. End Sub
  64. Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  65.     UserControl_MouseUp 1, 0, 0, 0
  66. End Sub
  67. Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  68.     If Enab = True Then UserControl_MouseDown Button, 1, 1, 1
  69. ':(áExpand Structure
  70. End Sub
  71. Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  72.     RaiseEvent Mouseup
  73. End Sub
  74. Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  75.     UserControl_MouseUp Button, 1, 1, 1
  76. End Sub
  77. Private Sub UserControl_Initialize()
  78.     Label1.Left = (UserControl.Width - Label1.Width) / 2
  79.     Label1.Top = (UserControl.Height - Label1.Height) / 2
  80.     UserControl.Backcolor = &H8000000F
  81.     Label1.Backcolor = &H8000000F
  82.     ReDraw False
  83. End Sub
  84. Private Sub UserControl_InitProperties()
  85.     Enab = True
  86.     Skinned = True
  87.     ReDraw False
  88. End Sub
  89. Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  90.     If Enab = True Then ReDraw True ':(áExpand Structure
  91. End Sub
  92. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  93.     RaiseEvent Mouseup
  94. End Sub
  95. Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  96.     ReDraw False
  97.     If Enab = True Then RaiseEvent Click   ':(áExpand Structure
  98. End Sub
  99. Private Sub UserControl_Paint()
  100.     ReDraw False
  101. End Sub
  102. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  103.     With PropBag
  104.         Label1.Caption = .ReadProperty("Caption", "Button")
  105.         UserControl.Height = .ReadProperty("Height", UserControl.Height)
  106.         UserControl.Width = .ReadProperty("Width", UserControl.Width)
  107.         Enab = .ReadProperty("Enabled", "True")
  108.     End With
  109.     Label1.Left = (UserControl.Width - Label1.Width) / 2
  110.     Label1.Top = (UserControl.Height - Label1.Height) / 2
  111. End Sub
  112. Private Sub UserControl_Resize()
  113.     Label1.Left = (UserControl.Width - Label1.Width) / 2
  114.     Label1.Top = (UserControl.Height - Label1.Height) / 2
  115.     ReDraw False
  116. End Sub
  117. Private Sub UserControl_IdeOK()
  118.     ReDraw False
  119. End Sub
  120. Private Sub ReDraw(Press As Boolean)
  121.     UserControl.Cls
  122.     If Press = True Then ':(áRemove Pleonasm
  123.         UserControl.ForeColor = &H808080
  124.         UserControl.Line (0, 0)-(UserControl.Width, 0)
  125.         UserControl.Line (0, 0)-(0, UserControl.Height)
  126.         UserControl.ForeColor = &HE0E0E0
  127.         UserControl.Line (UserControl.Width - 15, 0)-(UserControl.Width - 15, UserControl.Height)
  128.         UserControl.Line (0, UserControl.Height - 15)-(UserControl.Width, UserControl.Height - 15)
  129.     Else
  130.         UserControl.ForeColor = &HE0E0E0
  131.         UserControl.Line (0, 0)-(UserControl.Width, 0)
  132.         UserControl.Line (0, 0)-(0, UserControl.Height)
  133.         UserControl.ForeColor = &H808080
  134.         UserControl.Line (UserControl.Width - 15, 0)-(UserControl.Width - 15, UserControl.Height)
  135.         UserControl.Line (0, UserControl.Height - 15)-(UserControl.Width, UserControl.Height - 15)
  136.     End If
  137. End Sub
  138. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  139.     PropBag.WriteProperty "Enabled", Enab, "True"
  140.     PropBag.WriteProperty "Caption", Label1.Caption, "Button"
  141.     PropBag.WriteProperty "Height", UserControl.Height, UserControl.Height
  142.     PropBag.WriteProperty "Width", UserControl.Width, UserControl.Width
  143. End Sub
  144. ':)Code Fixer V3.0.9 (11/15/2006 12:12:21 PM) 5 + 173 = 178 Lines Thanks Ulli for inspiration and lots of code.
  145.