📄 usrpicbtn.ctl
字号:
VERSION 5.00
Begin VB.UserControl UsrPicBtn
ClientHeight = 750
ClientLeft = 0
ClientTop = 0
ClientWidth = 3405
ScaleHeight = 750
ScaleWidth = 3405
ToolboxBitmap = "UsrPicBtn.ctx":0000
Begin VB.PictureBox picContain
BorderStyle = 0 'None
Height = 735
Left = 0
ScaleHeight = 735
ScaleWidth = 3375
TabIndex = 1
Top = 0
Width = 3375
Begin VB.PictureBox PicUsrCmd
AutoRedraw = -1 'True
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 375
Left = 50
Picture = "UsrPicBtn.ctx":0312
ScaleHeight = 375
ScaleWidth = 375
TabIndex = 2
Top = 160
Width = 375
End
Begin VB.CommandButton cmdUsrPic
Height = 735
Left = 0
TabIndex = 0
Top = 0
Width = 3375
End
End
End
Attribute VB_Name = "UsrPicBtn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'Default Property Values:
Const m_def_ForeColor = 0
Const m_def_BackColor = 0
'Const m_def_ForeColor = 0
'Const m_def_Enabled = 0
Const m_def_BackStyle = 0
Const m_def_BorderStyle = 0
'Property Variables:
Dim m_ForeColor As Long
Dim m_BackColor As Long
'Dim m_ForeColor As Long
'Dim m_Enabled As Boolean
'Dim m_Font As Font
Dim m_BackStyle As Integer
Dim m_BorderStyle As Integer
'Event Declarations:
Event PicClick() 'MappingInfo=PicUsrCmd,PicUsrCmd,-1,Click
Event Click() 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,Click
'Event PicClick()
Event DblClick()
Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,KeyDown
Event KeyPress(KeyAscii As Integer) 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,KeyPress
Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,KeyUp
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,MouseDown
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,MouseMove
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=cmdUsrPic,cmdUsrPic,-1,MouseUp
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=8,0,0,0
Public Property Get BackColor() As Long
BackColor = m_BackColor
End Property
Public Property Let BackColor(ByVal New_BackColor As Long)
m_BackColor = New_BackColor
PropertyChanged "BackColor"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get BackStyle() As Integer
BackStyle = m_BackStyle
End Property
Public Property Let BackStyle(ByVal New_BackStyle As Integer)
m_BackStyle = New_BackStyle
PropertyChanged "BackStyle"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=7,0,0,0
Public Property Get BorderStyle() As Integer
BorderStyle = m_BorderStyle
End Property
Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
m_BorderStyle = New_BorderStyle
PropertyChanged "BorderStyle"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=5
Public Sub Refresh()
End Sub
'
'Private Sub PicUsrCmd_Click()
' 'cmdUsrPic.SetFocus
' 'Call cmdUsrPic_Click
' RaiseEvent PicClick
'End Sub
Private Sub picContain_GotFocus()
SendKeys "{tab}"
End Sub
Private Sub PicUsrCmd_GotFocus()
SendKeys "{tab}"
End Sub
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_BackColor = m_def_BackColor
' m_ForeColor = m_def_ForeColor
' m_Enabled = m_def_Enabled
' Set m_Font = Ambient.Font
m_BackStyle = m_def_BackStyle
m_BorderStyle = m_def_BorderStyle
m_ForeColor = m_def_ForeColor
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
m_BackStyle = PropBag.ReadProperty("BackStyle", m_def_BackStyle)
m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
cmdUsrPic.Caption = PropBag.ReadProperty("Caption", "")
cmdUsrPic.Enabled = PropBag.ReadProperty("Enabled", True)
m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
Set cmdUsrPic.Font = PropBag.ReadProperty("Font", Ambient.Font)
End Sub
Private Sub UserControl_Resize()
'限制位图按钮的高度
If UserControl.ScaleHeight <= 530 Then
UserControl.Enabled = False
UserControl.Height = 530
UserControl.Enabled = True
End If
picContain.Height = UserControl.ScaleHeight
If UserControl.ScaleWidth - picContain.Left > 0 Then
picContain.Width = UserControl.ScaleWidth - picContain.Left
End If
cmdUsrPic.Height = picContain.Height
cmdUsrPic.Width = picContain.Width
'设置图片高度始终居中
PicUsrCmd.Move cmdUsrPic.Left + 80, (cmdUsrPic.Height - PicUsrCmd.Height) / 2
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BackStyle", m_BackStyle, m_def_BackStyle)
Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
Call PropBag.WriteProperty("Picture", Picture, Nothing)
Call PropBag.WriteProperty("Caption", cmdUsrPic.Caption, "")
Call PropBag.WriteProperty("Enabled", cmdUsrPic.Enabled, True)
Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
Call PropBag.WriteProperty("Font", cmdUsrPic.Font, Ambient.Font)
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=PicUsrCmd,PicUsrCmd,-1,Picture
Public Property Get Picture() As Picture
Set Picture = PicUsrCmd.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set PicUsrCmd.Picture = New_Picture
PropertyChanged "Picture"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=cmdUsrPic,cmdUsrPic,-1,Caption
Public Property Get Caption() As String
Caption = cmdUsrPic.Caption
End Property
Public Property Let Caption(ByVal New_Caption As String)
cmdUsrPic.Caption() = Space$(7) & New_Caption
PropertyChanged "Caption"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=cmdUsrPic,cmdUsrPic,-1,Enabled
Public Property Get Enabled() As Boolean
Enabled = cmdUsrPic.Enabled
End Property
Public Property Let Enabled(ByVal New_Enabled As Boolean)
cmdUsrPic.Enabled() = New_Enabled
PropertyChanged "Enabled"
End Property
Private Sub cmdUsrPic_Click()
RaiseEvent Click
End Sub
Private Sub cmdUsrPic_KeyDown(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyDown(KeyCode, Shift)
End Sub
Private Sub cmdUsrPic_KeyPress(KeyAscii As Integer)
RaiseEvent KeyPress(KeyAscii)
End Sub
Private Sub cmdUsrPic_KeyUp(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyUp(KeyCode, Shift)
End Sub
Private Sub cmdUsrPic_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Private Sub cmdUsrPic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Private Sub cmdUsrPic_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!
'MemberInfo=8,0,0,0
Public Property Get ForeColor() As Long
ForeColor = m_ForeColor
End Property
Public Property Let ForeColor(ByVal New_ForeColor As Long)
m_ForeColor = New_ForeColor
PropertyChanged "ForeColor"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=cmdUsrPic,cmdUsrPic,-1,Font
Public Property Get Font() As Font
Set Font = cmdUsrPic.Font
End Property
Public Property Set Font(ByVal New_Font As Font)
Set cmdUsrPic.Font = New_Font
PropertyChanged "Font"
End Property
'定义了图片框控件的单击事件
Private Sub PicUsrCmd_Click()
RaiseEvent PicClick
'默认情况下,单击图片框,将引发标准按钮cmdUsrPic的
'单击事件,并且为该按钮设置焦点
'注意,用户也可以在自己的应用程序中为该事件添加代码
'就象对标准按钮添加代码一样,以处理特殊情况下的事件
cmdUsrPic.SetFocus
Call cmdUsrPic_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -