📄 buttonex.ctl
字号:
Public Property Let HighlightColor(ByVal NewValue As OLE_COLOR)
m_HighlightColor = NewValue
Call DrawButton(lState)
PropertyChanged "HighlightColor"
End Property
'Public Property Get HighlightPicture() As Boolean
' HighlightPicture = m_HighlightPicture
'End Property
'Public Property Let HighlightPicture(ByVal NewValue As Boolean)
'' m_HighlightPicture = NewValue
'
' Call DrawButton(btDisabled)
' PropertyChanged "HighlightPicture"
'End Property
Public Property Get MouseIcon() As Picture
Attribute MouseIcon.VB_Description = "Returns/sets a custom mouse icon."
Set MouseIcon = m_MouseIcon
End Property
Public Property Set MouseIcon(ByVal NewValue As Picture)
Set m_MouseIcon = NewValue
Set UserControl.MouseIcon = NewValue
' Set imgPicture.MouseIcon = NewValue
PropertyChanged "MouseIcon"
End Property
Public Property Get MousePointer() As MousePointerConstants
Attribute MousePointer.VB_Description = "Returns/sets the type of mouse pointer displayed when over part of the control."
MousePointer = m_MousePointer
End Property
Public Property Let MousePointer(ByVal NewValue As MousePointerConstants)
m_MousePointer = NewValue
UserControl.MousePointer = NewValue
' imgPicture.MousePointer = NewValue
PropertyChanged "MousePointer"
End Property
'Public Property Get Picture() As Picture
' Set Picture = m_Picture
'End Property
'Public Property Set Picture(ByVal NewValue As Picture)
' Set m_Picture = NewValue
' Set imgPicture.Picture = NewValue
' Call DrawButton(lState)
' PropertyChanged "Picture"
'End Property
'Public Property Get PictureDisabled() As Picture
' Set PictureDisabled = m_PictureDisabled
'End Property
'Public Property Set PictureDisabled(ByVal NewValue As Picture)
' Set m_PictureDisabled = NewValue
' PropertyChanged "PictureDisabled"
'End Property
'Public Property Get PictureDown() As Picture
' Set PictureDown = m_PictureDown
'End Property
'Public Property Set PictureDown(ByVal NewValue As Picture)
' Set m_PictureDown = NewValue
' PropertyChanged "PictureDown"
'End Property
'Public Property Get PictureFocus() As Picture
' Set PictureFocus = m_PictureFocus
'End Property
'Public Property Set PictureFocus(ByVal New_PictureFocus As Picture)
' Set m_PictureFocus = New_PictureFocus
' PropertyChanged "PictureFocus"
'End Property
'Public Property Get PictureOffsetX() As Long
' PictureOffsetX = m_PictureOffsetX
'End Property
'Public Property Let PictureOffsetX(ByVal NewValue As Long)
' m_PictureOffsetX = NewValue
'
' Call DrawButton(lState)
' PropertyChanged "PictureOffsetX"
'End Property
'Public Property Get PictureOffsetY() As Long
' PictureOffsetY = m_PictureOffsetY
'End Property
'Public Property Let PictureOffsetY(ByVal NewValue As Long)
' m_PictureOffsetY = NewValue
' Call DrawButton(lState)
' PropertyChanged "PictureOffsetY"
'End Property
'Public Property Get PictureOver() As Picture
' Set PictureOver = m_PictureOver
'End Property
'Public Property Set PictureOver(ByVal New_PictureOver As Picture)
' Set m_PictureOver = New_PictureOver
' PropertyChanged "PictureOver"
'End Property
Public Property Get RightToLeft() As Boolean
Attribute RightToLeft.VB_Description = "Determines text display direction and control visual appearance on a bidirectional system."
RightToLeft = m_RightToLeft
End Property
Public Property Let RightToLeft(ByVal NewValue As Boolean)
m_RightToLeft = NewValue
UserControl.RightToLeft = NewValue
' imgPicture.RightToLeft = NewValue
Call DrawButton(lState)
PropertyChanged "RightToLeft"
End Property
Public Property Get SkinDisabled() As Picture
Attribute SkinDisabled.VB_Description = "Returns/sets a graphic to be displayed for the control when it is disabled."
Set SkinDisabled = m_SkinDisabled
End Property
Public Property Set SkinDisabled(ByVal NewValue As Picture)
Set m_SkinDisabled = NewValue
Call DrawButton(lState)
PropertyChanged "SkinDisabled"
End Property
Public Property Get SkinDown() As Picture
Attribute SkinDown.VB_Description = "Returns/sets a graphic to be displayed for the control the mouse has been pressed over it."
Set SkinDown = m_SkinDown
End Property
Public Property Set SkinDown(ByVal NewValue As Picture)
Set m_SkinDown = NewValue
Call DrawButton(lState)
PropertyChanged "SkinDown"
End Property
Public Property Get SkinFocus() As Picture
Attribute SkinFocus.VB_Description = "Returns/sets a graphic to be displayed for the control when it default."
Set SkinFocus = m_SkinFocus
End Property
Public Property Set SkinFocus(ByVal NewValue As Picture)
Set m_SkinFocus = NewValue
Call DrawButton(lState)
PropertyChanged "SkinFocus"
End Property
Public Property Get SkinOver() As Picture
Attribute SkinOver.VB_Description = "Returns/sets a graphic to be displayed for the control when the mouse is over it."
Set SkinOver = m_SkinOver
End Property
Public Property Set SkinOver(ByVal NewValue As Picture)
Set m_SkinOver = NewValue
Call DrawButton(lState)
PropertyChanged "SkinOver"
End Property
Public Property Get SkinUp() As Picture
Attribute SkinUp.VB_Description = "Returns/sets a graphic to be displayed for the control."
Set SkinUp = m_SkinUp
End Property
Public Property Set SkinUp(ByVal NewValue As Picture)
Set m_SkinUp = NewValue
Call DrawButton(lState)
PropertyChanged "SkinUp"
End Property
Public Property Get Style() As StyleConstants
Attribute Style.VB_Description = "Returns/sets the style for the control."
Style = m_Style
End Property
Public Property Let Style(ByVal NewValue As StyleConstants)
m_Style = NewValue
Call DrawButton(lState)
PropertyChanged "Style"
End Property
Public Property Get ToolTipText() As String
Attribute ToolTipText.VB_Description = "Returns/sets the text displayed when the mouse cursor is over the control."
ToolTipText = m_ToolTipText
End Property
Public Property Let ToolTipText(ByVal NewValue As String)
m_ToolTipText = NewValue
' imgPicture.ToolTipText = NewValue
PropertyChanged "ToolTipText"
End Property
Public Property Get TransparentColor() As OLE_COLOR
Attribute TransparentColor.VB_Description = "Returns/sets the color of the Picture property to make transparent."
TransparentColor = m_TransparentColor
End Property
Public Property Let TransparentColor(ByVal NewValue As OLE_COLOR)
m_TransparentColor = NewValue
UserControl.MaskColor = NewValue
Call DrawButton(lState)
PropertyChanged "TransparentColor"
End Property
Public Property Get Value() As ValueConstants
Attribute Value.VB_Description = "Returns/sets a default state for the control."
Value = m_Value
End Property
Public Property Let Value(ByVal NewValue As ValueConstants)
m_Value = NewValue
Call DrawButton(m_Value)
PropertyChanged "Value"
End Property
Public Property Get WhatsThisHelpID() As Long
Attribute WhatsThisHelpID.VB_Description = "Returns/sets an associated help context ID for the control."
WhatsThisHelpID = m_WhatsThisHelpID
End Property
Public Property Let WhatsThisHelpID(ByVal NewValue As Long)
m_WhatsThisHelpID = NewValue
' imgPicture.WhatsThisHelpID = NewValue
PropertyChanged "WhatsThisHelpID"
End Property
'//---------------------------------------------------------------------------------------
'// Image functions
'//---------------------------------------------------------------------------------------
'Private Sub imgPicture_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Call UserControl_MouseDown(Button, Shift, imgPicture.Left + (X \ Screen.TwipsPerPixelX), imgPicture.Top + (Y \ Screen.TwipsPerPixelY))
'End Sub
'Private Sub imgPicture_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Call UserControl_MouseMove(Button, Shift, imgPicture.Left + (X \ Screen.TwipsPerPixelX), imgPicture.Top + (Y \ Screen.TwipsPerPixelY))
'End Sub
'Private Sub imgPicture_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Call UserControl_MouseUp(Button, Shift, imgPicture.Left + (X \ Screen.TwipsPerPixelX), imgPicture.Top + (Y \ Screen.TwipsPerPixelY))
'End Sub
'//---------------------------------------------------------------------------------------
'// Timer functions
'//---------------------------------------------------------------------------------------
Private Sub Timer1_Timer()
'check for mouse leaving control
Dim pnt As POINTAPI
GetCursorPos pnt
ScreenToClient UserControl.hWnd, pnt
If pnt.X < UserControl.ScaleLeft Or _
pnt.Y < UserControl.ScaleTop Or _
pnt.X > (UserControl.ScaleLeft + UserControl.ScaleWidth) Or _
pnt.Y > (UserControl.ScaleTop + UserControl.ScaleHeight) Then
Timer1.Enabled = False
Call RaiseEventEx("MouseExit")
'left focus
If lState <> btUp Then
Call DrawButton(btUp)
End If
bLeftFocus = True
Else
'gained focus
If bLeftFocus Then
Call DrawButton(btDown)
End If
End If
End Sub
'//---------------------------------------------------------------------------------------
'// UserControl functions
'//---------------------------------------------------------------------------------------
Private Sub UserControl_InitProperties()
'Initialize Properties for User Control
Appearance = m_def_Appearance
BackColor = m_def_BackColor
Caption = m_def_Caption
CaptionOffsetX = m_def_CaptionOffsetX
CaptionOffsetY = m_def_CaptionOffsetY
Enabled = m_def_Enabled
ForeColor = m_def_ForeColor
Set Font = Ambient.Font
HighlightColor = m_def_HighlightColor
' HighlightPicture = m_def_HighlightPicture
Set MouseIcon = LoadPicture("")
MousePointer = m_def_MousePointer
' Set Picture = LoadPicture("")
' Set PictureDisabled = LoadPicture("")
' Set PictureDown = LoadPicture("")
' Set PictureFocus = LoadPicture("")
' PictureOffsetX = m_def_PictureOffsetX
' PictureOffsetY = m_def_PictureOffsetY
' Set PictureOver = LoadPicture("")
RightToLeft = m_def_RightToLeft
Set SkinDisabled = LoadPicture("")
Set SkinDown = LoadPicture("")
Set SkinFocus = LoadPicture("")
Set SkinOver = LoadPicture("")
Set SkinUp = LoadPicture("")
Style = m_def_Style
ToolTipText = m_def_ToolTipText
TransparentColor = m_def_TransparentColor
Value = m_def_Value
WhatsThisHelpID = m_def_WhatsThisHelpID
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
'Load property values from storage
Appearance = PropBag.ReadProperty("Appearance", m_def_Appearance)
BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
Caption = PropBag.ReadProperty("Caption", m_def_Caption)
CaptionOffsetX = PropBag.ReadProperty("CaptionOffsetX", m_def_CaptionOffsetX)
CaptionOffsetY = PropBag.ReadProperty("CaptionOffsetY", m_def_CaptionOffsetY)
Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
Set Font = PropBag.ReadProperty("Font", Ambient.Font)
HighlightColor = PropBag.ReadProperty("HighlightColor", m_def_HighlightColor)
' HighlightPicture = PropBag.ReadProperty("HighlightPicture", m_def_HighlightPicture)
Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
MousePointer = PropBag.ReadProperty("MousePointer", m_def_MousePointer)
' Set Picture = PropBag.ReadProperty("Picture", Nothing)
' Set PictureDisabled = PropBag.ReadProperty("PictureDisabled", Nothing)
' Set PictureDown = PropBag.ReadProperty("PictureDown", Nothing)
' Set PictureFocus = PropBag.ReadProperty("PictureFocus", Nothing)
' PictureOffsetX = PropBag.ReadProperty("PictureOffsetX", m_def_PictureOffsetX)
' PictureOffsetY = PropBag.ReadProperty("PictureOffsetY", m_def_PictureOffsetY)
' Set PictureOver = PropBag.ReadProperty("PictureOver", Nothing)
RightToLeft = PropBag.ReadProperty("RightToLeft", m_def_RightToLeft)
Set SkinDisabled = PropBag.ReadProperty("SkinDisabled", Nothing)
Set SkinDown = PropBag.ReadProperty("SkinDown", Nothing)
Set SkinFocus = PropBag.ReadProperty("SkinFocus", Nothing)
Set SkinOver = PropBag.ReadProperty("SkinOver", Nothing)
Set SkinUp = PropBag.ReadProperty("SkinUp", Nothing)
Style = PropBag.ReadProperty("Style", m_def_Style)
ToolTipText = PropBag.ReadProperty("ToolTipText", m_def_ToolTipText)
TransparentColor = PropBag.ReadProperty("TransparentColor", m_def_TransparentColor)
Value = PropBag.ReadProperty("Value", m_def_Value)
WhatsThisHelpID = PropBag.ReadProperty("WhatsThisHelpID", m_def_WhatsThisHelpID)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
'Write property values to storage
Call PropBag.WriteProperty("Appearance", m_Appearance, m_def_Appearance)
Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
Call PropBag.WriteProperty("Caption", m_Caption, m_def_Caption)
Call PropBag.WriteProperty("CaptionOffsetX", m_CaptionOffsetX, m_def_CaptionOffsetX)
Call PropBag.WriteProperty("CaptionOffsetY", m_CaptionOffsetY, m_def_CaptionOffsetY)
Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
Call PropBag.WriteProperty("Font", m_Font, Ambient.Font)
Call PropBag.WriteProperty("HighlightColor", m_HighlightColor, m_def_HighlightColor)
' Call PropBag.WriteProperty("HighlightPicture", m_HighlightPicture, m_def_HighlightPicture)
' Call PropBag.WriteProperty("Picture", m_Picture, Nothing)
' Call PropBag.WriteProperty("PictureDisabled", m_PictureDisabled, Nothing)
' Call PropBag.WriteProperty("PictureDown", m_PictureDown, Nothing)
' Call PropBag.WriteProperty("PictureFocus", m_PictureFocus, Nothing)
' Call PropBag.WriteProperty("PictureOffsetX", m_PictureOffsetX, m_def_PictureOffsetX)
' Call PropBag.WriteProperty("PictureOffsetY", m_PictureOffsetY, m_def_PictureOffsetY)
' Call PropBag.WriteProperty("PictureOver", m_PictureOver, Nothing)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -