Когда - то давно написал. Если немного криво - сам поправь.
На UC закинь два лабела: Lbl & Lbl2
А вот код:
Dim m_Font As Font
Dim m_FirstColor As OLE_COLOR
Dim m_SecondColor As OLE_COLOR
Dim m_BackColor As OLE_COLOR
Dim m_intErval As Integer
Const m_def_FirstColor = vb3DDKShadow
Const m_def_SecondColor = vb3DHighlight
Const m_def_BackColor = vbButtonFace
Const m_def_inTerval = 1
Event Click()
Event DblClick()
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Private Sub lbl_Change()
UserControl_Resize
End Sub
Private Sub lbl_Click()
RaiseEvent Click
End Sub
Private Sub lbl_DblClick()
RaiseEvent DblClick
End Sub
Private Sub lbl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Private Sub lbl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Private Sub lbl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub
Private Sub UserControl_Initialize()
UserControl_Resize
End Sub
Private Sub UserControl_InitProperties()
Caption = Ambient.DisplayName
Enabled = True
Set Font = UserControl.Ambient.Font
FirstColor = m_def_FirstColor
SecondColor = m_def_SecondColor
BackColor = m_def_BackColor
Interval = m_def_inTerval
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Enabled = PropBag.ReadProperty("Enabled", True)
Set Font = PropBag.ReadProperty("Font", UserControl.Ambient.Font)
FirstColor = PropBag.ReadProperty("FirstColor", m_def_FirstColor)
SecondColor = PropBag.ReadProperty("SecondColor", m_def_SecondColor)
BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
Interval = PropBag.ReadProperty("Interval", m_def_inTerval)
Caption = PropBag.ReadProperty("Caption", Ambient.DisplayName)
End Sub
Private Sub UserControl_Resize()
On Error Resume Next
UserControl.Height = Lbl.Height + (15 * Interval)
UserControl.Width = Lbl.Width + (15 * Interval)
Call UserControl_Show
End Sub
Public Property Get Enabled() As Boolean
Enabled = UserControl.Enabled
End Property
Public Property Let Enabled(ByVal New_Enabled As Boolean)
UserControl.Enabled() = New_Enabled
PropertyChanged "Enabled"
End Property
Private Sub UserControl_Show()
Lbl.Top = 0
Lbl.Left = 0
Lbl2.Top = 15 * Interval
Lbl2.Left = 15 * Interval
Lbl2.Caption = Lbl.Caption
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
On Error Resume Next
Call PropBag.WriteProperty("Caption", Lbl.Caption, Ambient.DisplayName)
Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
Call PropBag.WriteProperty("Font", m_Font, UserControl.Ambient.Font)
Call PropBag.WriteProperty("FirstColor", m_FirstColor, m_def_FirstColor)
Call PropBag.WriteProperty("SecondColor", m_SecondColor, m_def_SecondColor)
Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
Call PropBag.WriteProperty("Interval", m_intErval, m_def_inTerval)
End Sub
Public Property Get Font() As Font
Set Font = m_Font
End Property
Public Property Set Font(ByVal vNewFont As Font)
Set m_Font = vNewFont
Set UserControl.Font = vNewFont
Set Lbl.Font = m_Font
Set Lbl2.Font = m_Font
Call UserControl_Resize
PropertyChanged "Font"
End Property
Public Property Get FirstColor() As OLE_COLOR
FirstColor = m_FirstColor
End Property
Public Property Get SecondColor() As OLE_COLOR
SecondColor = m_SecondColor
End Property
Public Property Get BackColor() As OLE_COLOR
BackColor = m_BackColor
End Property
Public Property Get Interval() As Integer
Interval = m_intErval
End Property
Public Property Let FirstColor(ByVal New_FirstColor As OLE_COLOR)
m_FirstColor = New_FirstColor
PropertyChanged "FirstColor"
Lbl.ForeColor = m_FirstColor
UserControl_Resize
End Property
Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
m_BackColor = New_BackColor
PropertyChanged "BackColor"
UserControl.BackColor = m_BackColor
UserControl_Resize
End Property
Public Property Let SecondColor(ByVal New_SecondColor As OLE_COLOR)
m_SecondColor = New_SecondColor
PropertyChanged "SecondColor"
Lbl2.ForeColor = m_SecondColor
UserControl_Resize
End Property
Public Property Let Interval(ByVal New_Interval As Integer)
m_intErval = New_Interval
PropertyChanged "Interval"
UserControl_Resize
End Property
Public Property Get Caption() As String
Caption = Lbl.Caption
End Property
Public Property Let Caption(ByVal vNewCaption As String)
Lbl.Caption() = vNewCaption
Call UserControl_Resize
PropertyChanged "Caption"
End Property
С тебя бутылка ))
Ответить
|