ActiveX

Листинг для Урока 5 (продолжение)

ActiveX Control "Indicator"

Indicator: Num

'*****************************************************************
'
Урок 5
'ActiveX Control - "Indicator"
'
Листинг
'*****************************************************************

Option Explicit

 

'*****************************************************************
'Объявление констант
'*****************************************************************

Const m_def_Numeric = 0

 

'*****************************************************************
'Объявление внутренних переменных
'*****************************************************************

Dim m_Numeric As Integer

 

'*****************************************************************
'Объявление событий
'*****************************************************************

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)

 

'*****************************************************************
'Свойства контрола
'*****************************************************************

Public Property Get Numeric() As Integer

Numeric = m_Numeric

End Property

 

Public Property Let Numeric(ByVal New_Numeric As Integer)

'если не число

If Not IsNumeric(New_Numeric) Then Exit Property

m_Numeric = New_Numeric

Select Case m_Numeric

Case 0

Ind1.Entries = "1111101"

Case 1

Ind1.Entries = "0011000"

Case 2

Ind1.Entries = "0110111"

Case 3

Ind1.Entries = "0011111"

Case 4

Ind1.Entries = "1011010"

Case 5

Ind1.Entries = "1001111"

Case 6

Ind1.Entries = "1101111"

Case 7

Ind1.Entries = "0011100"

Case 8

Ind1.Entries = "1111111"

Case 9

Ind1.Entries = "1011111"

Case Else

Ind1.Entries = "0000000"

End Select

PropertyChanged "Numeric"

End Property

 

Public Property Get BackColor() As OLE_COLOR

BackColor = Ind1.BackColor

End Property

 

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)

Ind1.BackColor() = New_BackColor

PropertyChanged "BackColor"

End Property

 

Public Property Get ForeColor() As OLE_COLOR

ForeColor = Ind1.ForeColor

End Property

 

Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)

Ind1.ForeColor() = New_ForeColor

PropertyChanged "ForeColor"

End Property

 

Public Property Get Thickness() As Long

Thickness = Ind1.Thickness

End Property

 

Public Property Let Thickness(ByVal New_Thickness As Long)

Ind1.Thickness() = New_Thickness

PropertyChanged "Thickness"

End Property

 

'*****************************************************************
'Обработка событий UserControl и контрола
Indicator: Num
'*****************************************************************

Private Sub Ind1_Click()

RaiseEvent Click

End Sub

 

Private Sub Ind1_DblClick()

RaiseEvent DblClick

End Sub

 

Private Sub Ind1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

RaiseEvent MouseDown(Button, Shift, X, Y)

End Sub

 

Private Sub Ind1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

RaiseEvent MouseMove(Button, Shift, X, Y)

End Sub

 

Private Sub Ind1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

RaiseEvent MouseUp(Button, Shift, X, Y)

End Sub

 

Private Sub UserControl_InitProperties()

m_Numeric = m_def_Numeric

End Sub

 

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

Ind1.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)

Ind1.ForeColor = PropBag.ReadProperty("ForeColor", &HFF0000)

Ind1.Thickness = PropBag.ReadProperty("Thickness", 0)

m_Numeric = PropBag.ReadProperty("Numeric", m_def_Numeric)

End Sub

 

Private Sub UserControl_Resize()

Ind1.Move 0, 0, ScaleWidth, ScaleHeight

End Sub

 

Private Sub UserControl_Show()

Numeric = m_Numeric

End Sub

 

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

Call PropBag.WriteProperty("BackColor", Ind1.BackColor, &H8000000F)

Call PropBag.WriteProperty("ForeColor", Ind1.ForeColor, &HFF0000)

Call PropBag.WriteProperty("Thickness", Ind1.Thickness, 0)

Call PropBag.WriteProperty("Numeric", m_Numeric, m_def_Numeric)

End Sub

 

 К статье

Hosted by uCoz