📄 userctl1.ctl
字号:
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
CaptionTitle = defKAPSIYON
m_UseBorders = m_def_UseBorders
Set Font = UserControl.Ambient.Font
m_ButtonTextColor = m_def_ButtonTextColor
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set ButtonIcon = PropBag.ReadProperty("ButtonIcon", Nothing)
Set ButtonIcon_MouseMove = PropBag.ReadProperty("ButtonIcon_MouseMove", Nothing)
CaptionTitle = PropBag.ReadProperty(sKAPSIYONE, defKAPSIYON)
Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
UserControl.BackColor = PropBag.ReadProperty("ButtonBackColor", &H8000000F)
m_UseBorders = PropBag.ReadProperty("UseBorders", m_def_UseBorders)
Set UserControl.Font = PropBag.ReadProperty("Font", UserControl.Ambient.Font)
Set Font = PropBag.ReadProperty("FONT", Nothing)
UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
m_ButtonTextColor = PropBag.ReadProperty("ButtonTextColor", m_def_ButtonTextColor)
UserControl.ForeColor = m_ButtonTextColor
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("ButtonIcon", Me.ButtonIcon, Nothing)
Call PropBag.WriteProperty("ButtonIcon_MouseMove", Me.ButtonIcon_MouseMove, Nothing)
Call PropBag.WriteProperty(sKAPSIYONE, m_KAPSIYON, defKAPSIYON)
Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
Call PropBag.WriteProperty("Picture", Picture, Nothing)
Call PropBag.WriteProperty("ButtonBackColor", UserControl.BackColor, &H8000000F)
Call PropBag.WriteProperty("UseBorders", m_UseBorders, m_def_UseBorders)
PropBag.WriteProperty "Font", UserControl.Font, UserControl.Ambient.Font
Call PropBag.WriteProperty("FONT", Font, Nothing)
Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
Call PropBag.WriteProperty("ButtonTextColor", m_ButtonTextColor, m_def_ButtonTextColor)
End Sub
Public Property Get MouseIcon() As Picture
Attribute MouseIcon.VB_Description = "Sets a custom mouse icon."
Set MouseIcon = UserControl.MouseIcon
End Property
Public Property Set MouseIcon(ByVal New_MouseIcon As Picture)
Set UserControl.MouseIcon = New_MouseIcon
UserControl_Resize
PropertyChanged "MouseIcon"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Picture
Public Property Get Picture() As Picture
Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
Set Picture = UserControl.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set UserControl.Picture = New_Picture
PropertyChanged "Picture"
UserControl_Resize
End Property
Public Property Get ButtonBackColor() As OLE_COLOR
Attribute ButtonBackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
ButtonBackColor = UserControl.BackColor
End Property
Public Property Let ButtonBackColor(ByVal New_ButtonBackColor As OLE_COLOR)
UserControl.BackColor() = New_ButtonBackColor
PropertyChanged "ButtonBackColor"
UserControl_Resize
End Property
Public Property Get ButtonIcon() As Picture
Set ButtonIcon = IMAGE_INITIAL.Picture
End Property
Public Property Set ButtonIcon(ByVal NewButtonIcon As Picture)
Set IMAGE_INITIAL.Picture = NewButtonIcon
Set IMAGERESTORE.Picture = NewButtonIcon
IMAGE_INITIAL.Top = 1
UserControl_Resize
PropertyChanged "ButtonIcon"
End Property
Public Property Get ButtonIcon_MouseMove() As Picture
Set ButtonIcon_MouseMove = IMAGEMOUSEOVER.Picture
End Property
Public Property Set ButtonIcon_MouseMove(ByVal NewButtonIcon_MouseMove As Picture)
Set IMAGEMOUSEOVER.Picture = NewButtonIcon_MouseMove
UserControl_Resize
PropertyChanged "ButtonIcon_MouseMove"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,1
Public Property Get UseBorders() As Boolean
Attribute UseBorders.VB_Description = "Set type of border when the mouse is over the control"
UseBorders = m_UseBorders
End Property
Public Property Let UseBorders(ByVal New_UseBorders As Boolean)
m_UseBorders = New_UseBorders
PropertyChanged "UseBorders"
UserControl_Resize
End Property
''WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
''MappingInfo=UserControl,UserControl,-1,ForeColor
'Public Property Get ButtonTextColor() As OLE_COLOR
' ButtonTextColor = UserControl.ForeColor
'End Property
'
'Public Property Let ButtonTextColor(ByVal New_ButtonTextColor As OLE_COLOR)
' UserControl.ForeColor() = New_ButtonTextColor
' UserControl_Resize
' PropertyChanged "ButtonTextColor"
'End Property
Public Sub DRAWUP()
If UseBorders = True Then
Dim Bar As RECT
AutoRedraw = True
With Bar
.Left = UserControl.ScaleLeft
.Top = UserControl.ScaleTop
.Right = UserControl.Width / 15
.Bottom = UserControl.Height / 15
End With
Call DrawEdge(hdc, Bar, EDGE_RAISED, BF_RECT)
' Call DrawEdge(hdc, Bar, BDR_RAISEDOUTER, &H100F) 'You can use this
' to draw a SOFTER border.
' instead of the previous line
UserControl.Refresh 'refresh to clear previous border style
End If
End Sub
Public Sub DRAWDOWN()
If UseBorders = True Then
Dim Bar As RECT
AutoRedraw = True 'This should be True prevent text from getting erased
' when the form is minimized and restored again.
With Bar
.Left = UserControl.ScaleLeft
.Top = UserControl.ScaleTop
.Right = UserControl.Width / 15
.Bottom = UserControl.Height / 15
End With
Call DrawEdge(hdc, Bar, EDGE_SUNKEN, BF_RECT)
UserControl.Refresh 'refresh to clear previous border style
End If
End Sub
Private Sub TEXTBOYUTUNUBUL() 'We are figuring out the length of the text here
Dim BYTUM As BOYUT
Call GETTEXTDIM(hdc, CaptionTitle, Len(CaptionTitle), BYTUM)
If IMAGE_INITIAL.Picture = 0 Or IMAGERESTORE.Picture = 0 Then
TEXT_LEFT = (UserControl.Width \ Screen.TwipsPerPixelX - BYTUM.BOYUT_X) \ 2
Else
TEXT_LEFT = (IMAGE_INITIAL.Width \ Screen.TwipsPerPixelX) + 5
End If
TEXT_TOP = (UserControl.Height \ Screen.TwipsPerPixelY - BYTUM.BOYUT_Y) \ 2
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Font
Public Property Get Font() As StdFont
Attribute Font.VB_Description = "Returns a Font object."
Set Font = UserControl.Font
End Property
Public Property Set Font(ByVal New_FONT As StdFont)
Set UserControl.Font = New_FONT
UserControl_Resize
PropertyChanged "FONT"
End Property
Private Sub UserControl_Resize()
If UserControl.Enabled = False Then
UserControl.ForeColor() = vb3DShadow 'Well, I use vb3Dshadow to display disabled text
Else
UserControl.ForeColor = m_ButtonTextColor
End If
UserControl.Cls
TEXTBOYUTUNUBUL
Call DRAWTHETEXT(UserControl.hdc, TEXT_LEFT, TEXT_TOP, CaptionTitle, Len(CaptionTitle))
IMAGE_INITIAL.Move 45, (UserControl.Height / 2) - IMAGE_INITIAL.Height / 2 ', UserControl.Width / 15
SUANKI_IMAGE_POZISYONU
If Not UserControl.Ambient.UserMode Then DRAWUP
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Enabled
Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
Enabled = UserControl.Enabled
End Property
Public Property Let Enabled(ByVal New_Enabled As Boolean)
UserControl.Enabled() = New_Enabled
PropertyChanged "Enabled"
UserControl_Resize
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=10,0,0,0
Public Property Get ButtonTextColor() As OLE_COLOR
Attribute ButtonTextColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
ButtonTextColor = m_ButtonTextColor
End Property
Public Property Let ButtonTextColor(ByVal New_ButtonTextColor As OLE_COLOR)
m_ButtonTextColor = New_ButtonTextColor
UserControl.ForeColor() = New_ButtonTextColor
UserControl_Resize
PropertyChanged "ButtonTextColor"
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -