Вот весь контрол, может, кому-то пригодится:
Option Explicit
'Default Property Values:
Const m_def_IsPressed = 0
'Property Variables:
Dim m_IsPressed As Boolean
'Event Declarations:
Event Click() 'MappingInfo=imgButton,imgButton,-1,Click
Event DblClick() 'MappingInfo=imgButton,imgButton,-1,DblClick
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=imgButton,imgButton,-1,MouseDown
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=imgButton,imgButton,-1,MouseMove
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=imgButton,imgButton,-1,MouseUp
Private Sub imgButton_Click()
RaiseEvent Click
If IsPressed = True Then
IsPressed = False
imgButton.Picture = imgNormal.Picture
Else
IsPressed = True
imgButton.Picture = imgPressed.Picture
End If
End Sub
Private Sub imgButton_DblClick()
RaiseEvent DblClick
If IsPressed = True Then
IsPressed = False
imgButton.Picture = imgNormal.Picture
Else
IsPressed = True
imgButton.Picture = imgPressed.Picture
End If
End Sub
Private Sub imgButton_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Private Sub imgButton_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Private Sub imgButton_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=imgNormal,imgNormal,-1,Picture
Public Property Get PictureNormal() As Picture
Set PictureNormal = imgNormal.Picture
End Property
Public Property Set PictureNormal(ByVal New_PictureNormal As Picture)
Set imgNormal.Picture = New_PictureNormal
PropertyChanged "PictureNormal"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=imgPressed,imgPressed,-1,Picture
Public Property Get PicturePressed() As Picture
Set PicturePressed = imgPressed.Picture
End Property
Public Property Set PicturePressed(ByVal New_PicturePressed As Picture)
Set imgPressed.Picture = New_PicturePressed
PropertyChanged "PicturePressed"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,0
Public Property Get IsPressed() As Boolean
IsPressed = m_IsPressed
If IsPressed = False Then
imgButton.Picture = imgNormal.Picture
Else
imgButton.Picture = imgPressed.Picture
End If
End Property
Public Property Let IsPressed(ByVal New_IsPressed As Boolean)
m_IsPressed = New_IsPressed
PropertyChanged "IsPressed"
If IsPressed = False Then
imgButton.Picture = imgNormal.Picture
Else
imgButton.Picture = imgPressed.Picture
End If
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_IsPressed = m_def_IsPressed
End Sub
Private Sub UserControl_Paint()
If imgNormal.Picture <> 0 Then
If IsPressed = False Then
imgButton.Picture = imgNormal.Picture
Else
imgButton.Picture = imgPressed.Picture
End If
End If
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set imgNormal.Picture = PropBag.ReadProperty("PictureNormal", Nothing)
Set imgPressed.Picture = PropBag.ReadProperty("PicturePressed", Nothing)
m_IsPressed = PropBag.ReadProperty("IsPressed", m_def_IsPressed)
End Sub
Private Sub UserControl_Resize()
imgButton.Width = UserControl.Width
imgButton.Height = UserControl.Height
imgNormal.Width = UserControl.Width
imgNormal.Height = UserControl.Height
imgPressed.Width = UserControl.Width
imgPressed.Height = UserControl.Height
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("PictureNormal", imgNormal.Picture, Nothing)
Call PropBag.WriteProperty("PicturePressed", imgPressed.Picture, Nothing)
Call PropBag.WriteProperty("IsPressed", m_IsPressed, m_def_IsPressed)
End Sub
Ответить
|