⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mctoolbar.ctl

📁 VB写的一个IDE开发环境,支持脚本运行,内置了一个简单的编译器,可以直接生成EXE.. 推荐下载!
💻 CTL
📖 第 1 页 / 共 5 页
字号:
        RedrawControl
    End If
    
End Property


Public Property Get HoverColor() As OLE_COLOR
    HoverColor = m_HoverColor
End Property

Public Property Let HoverColor(ByVal New_HoverColor As OLE_COLOR)
    m_HoverColor = New_HoverColor
    PropertyChanged "HoverColor"
    RedrawControl
End Property


Public Property Get ButtonToolTip() As String
    If Not m_Button_Index = -1 Then
        ButtonToolTip = m_ButtonItem(m_Button_Index).TB_ToolTipText
    End If
End Property

Public Property Let ButtonToolTip(ByVal New_ButtonToolTip As String)
    If Not m_Button_Index = -1 Then
        m_ButtonItem(m_Button_Index).TB_ToolTipText = New_ButtonToolTip
        PropertyChanged "ButtonToolTip"
    End If
End Property


Public Property Get ToolTipBackCol() As OLE_COLOR
    ToolTipBackCol = m_ToolTipBackCol
End Property

Public Property Let ToolTipBackCol(ByVal New_ToolTipBackCol As OLE_COLOR)
    m_ToolTipBackCol = New_ToolTipBackCol
    PropertyChanged "ToolTipBackCol"
End Property


Public Property Get ToolTipForeCol() As OLE_COLOR
    ToolTipForeCol = m_ToolTipForeCol
End Property

Public Property Let ToolTipForeCol(ByVal New_ToolTipForeCol As OLE_COLOR)
    m_ToolTipForeCol = New_ToolTipForeCol
    PropertyChanged "ToolTipForeCol"
End Property


Public Property Get TooTipStyle() As TooTipStyleEnum
    TooTipStyle = m_TooTipStyle
End Property

Public Property Let TooTipStyle(ByVal New_TooTipStyle As TooTipStyleEnum)
    m_TooTipStyle = New_TooTipStyle
    PropertyChanged "TooTipStyle"
End Property


Public Property Get ButtonToolTipIcon() As ToolTipIconEnum
    If Not m_Button_Index = -1 Then
        ButtonToolTipIcon = m_ButtonItem(m_Button_Index).TB_ToolTipIcon
    End If
End Property

Public Property Let ButtonToolTipIcon(ByVal New_ButtonToolTipIcon As ToolTipIconEnum)
    If Not m_Button_Index = -1 Then
        m_ButtonItem(m_Button_Index).TB_ToolTipIcon = New_ButtonToolTipIcon
        PropertyChanged "ButtonToolTipIcon"
    End If
End Property


Public Property Get BackGradient() As GradientDirectionEnum
    BackGradient = m_BackGradient
End Property

Public Property Let BackGradient(ByVal New_BackGradient As GradientDirectionEnum)
    m_BackGradient = New_BackGradient
    PropertyChanged "BackGradient"
    m_BackDrawn = False
    RedrawControl
End Property


Public Property Get BackGradientCol() As OLE_COLOR
    BackGradientCol = m_BackGradientCol
End Property

Public Property Let BackGradientCol(ByVal New_BackGradientCol As OLE_COLOR)
    m_BackGradientCol = New_BackGradientCol
    PropertyChanged "BackGradientCol"
    m_BackDrawn = False
    RedrawControl
End Property


Public Property Get ButtonsStyle() As ButtonsStyleEnum
    ButtonsStyle = m_ButtonsStyle
End Property

Public Property Let ButtonsStyle(ByVal New_ButtonsStyle As ButtonsStyleEnum)
    m_ButtonsStyle = New_ButtonsStyle
    ApplyTheme New_ButtonsStyle
    m_BackDrawn = False
    PropertyChanged "ButtonsStyle"
    RedrawControl
End Property


Public Property Get ButtonEnabled() As Boolean
    If Not m_Button_Index = -1 Then
        ButtonEnabled = m_ButtonItem(m_Button_Index).TB_Enabled
    End If
End Property

Public Property Let ButtonEnabled(ByVal New_ButtonEnabled As Boolean)
    If Not m_Button_Index = -1 Then
        m_ButtonItem(m_Button_Index).TB_Enabled = New_ButtonEnabled
        PropertyChanged "ButtonEnabled"
        RedrawControl
    End If
End Property


Public Property Get BorderColor() As OLE_COLOR
    BorderColor = m_BorderColor
End Property

Public Property Let BorderColor(ByVal New_BorderColor As OLE_COLOR)
    m_BorderColor = New_BorderColor
    PropertyChanged "BorderColor"
    RedrawControl
End Property

Public Property Get HoverIconShadow() As Boolean
    HoverIconShadow = m_HoverIconShadow
End Property

Public Property Let HoverIconShadow(ByVal New_HoverIconShadow As Boolean)
    m_HoverIconShadow = New_HoverIconShadow
    PropertyChanged "HoverIconShadow"
    RedrawControl
End Property


Public Property Get ButtonPressed() As Boolean
    If Not m_Button_Index = -1 Then
        ButtonPressed = m_ButtonItem(m_Button_Index).TB_Pressed
    End If
End Property

Public Property Let ButtonPressed(ByVal New_ButtonPressed As Boolean)
    If Not m_Button_Index = -1 Then
        m_ButtonItem(m_Button_Index).TB_Pressed = New_ButtonPressed
        PropertyChanged "ButtonPressed"
        RedrawControl
    End If
End Property


Public Property Get ButtonIconAllignment() As IconAllignmentEnum
    If Not m_Button_Index = -1 Then
        ButtonIconAllignment = m_ButtonItem(m_Button_Index).TB_IconAllignment
    End If
End Property

Public Property Let ButtonIconAllignment(ByVal New_ButtonIconAllignment As IconAllignmentEnum)
    If Not m_Button_Index = -1 Then
        m_ButtonItem(m_Button_Index).TB_IconAllignment = New_ButtonIconAllignment
        PropertyChanged "ButtonIconAllignment"
        RedrawControl
    End If
End Property


Public Property Get ShowSeperator() As Boolean
    ShowSeperator = m_ShowSeperator
End Property

Public Property Let ShowSeperator(ByVal New_ShowSeperator As Boolean)
    m_ShowSeperator = New_ShowSeperator
    PropertyChanged "ShowSeperator"
    RedrawControl
End Property


' Remove Button
Public Property Get ButtonRemove() As UserOptionEnum
    ButtonRemove = -1
End Property

Public Property Let ButtonRemove(ByVal vNewValue As UserOptionEnum)
    
    If vNewValue = 1 Then
        RemoveButton m_Button_Index
        If m_Button_Index >= m_Button_Count Then m_Button_Index = m_Button_Count - 1
        RedrawControl
    End If
    
End Property


' Move Button Index
Public Property Get ButtonMoveTo() As Long
    ButtonMoveTo = -1
End Property

Public Property Let ButtonMoveTo(ByVal vNewValue As Long)

    MoveButtonTo m_Button_Index, vNewValue
    m_Button_Index = vNewValue
    RedrawControl
    
End Property

' Insert to Button Index
Public Property Get ButtonInsertTo() As Long
    ButtonInsertTo = -1
End Property

Public Property Let ButtonInsertTo(ByVal vNewValue As Long)

    InsertButtonTo m_Button_Index, vNewValue
    m_Button_Index = vNewValue
    RedrawControl
        
End Property


Private Sub UserControl_Click()
    RaiseEvent Click(m_Button_Index)
End Sub

Private Sub UserControl_DblClick()
    m_Pressed = True
    RedrawControl
    RaiseEvent DblClick(m_Button_Index)
End Sub

Private Sub UserControl_Initialize()
    'debug.Print "----------------------------------------"
    'debug.Print "INITIALIZED!"
    'debug.Print "----------------------------------------"
    m_hMode = LoadLibrary("shell32.dll")
    m_bIsNT = IsNT
End Sub

'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
    m_Appearance = m_def_Appearance
    m_BackColor = m_def_BackColor
    m_BorderStyle = m_def_BorderStyle
    m_Enabled = m_def_Enabled
    Set m_Font = Ambient.Font
    m_ForeColor = m_def_ForeColor
    m_Button_Count = m_def_Button_Count
    m_Button_Index = m_def_Button_Index
    Set m_BackGround = LoadPicture("")
    m_ButtonsWidth = m_def_ButtonsWidth
    m_ButtonsHeight = m_def_ButtonsHeight
    m_ButtonsPerRow = m_def_ButtonsPerRow
    m_HoverColor = m_def_HoverColor
    m_BackGradient = m_def_BackGradient
    m_BackGradientCol = m_def_BackGradientCol
    m_ToolTipBackCol = m_def_ToolTipBackCol
    m_ToolTipForeCol = m_def_ToolTipForeCol
    m_ButtonsStyle = m_def_ButtonsStyle
    m_BorderColor = m_def_BorderColor
    m_HoverIconShadow = m_def_HoverIconShadow
    m_ButtonsSeperatorWidth = m_def_ButtonsSeperatorWidth
    m_ShowSeperator = m_def_ShowSeperator
    
    ReDim m_ButtonItem(0)
    m_ButtonItem(0).TB_Caption = m_def_ButtonCaption & "0"
    m_ButtonItem(0).TB_ToolTipText = m_def_ButtonToolTip
    m_ButtonItem(0).TB_Enabled = m_def_Enabled
    m_ButtonItem(0).TB_IconAllignment = m_def_ButtonIconAllignment
    m_ButtonItem(0).TB_Pressed = m_def_ButtonPressed
    m_ButtonItem(0).TB_ToolTipIcon = m_def_ButtonToolTipIcon

End Sub

Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
    m_Pressed = True
    RaiseEvent KeyDown(m_Button_Index, KeyCode, Shift)
End Sub

Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
    m_Pressed = False
    RaiseEvent KeyUp(m_Button_Index, KeyCode, Shift)
End Sub

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Not m_Button_Index = -1 Then
        m_Pressed = True
        RedrawControl
        RaiseEvent MouseDown(m_Button_Index, Button, Shift, X, Y)
    End If
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nIndex As Long

    On Error GoTo Handle
    ' Calculate the Hover item
    nIndex = GetButtonFromXY(X, Y)
    
    ' Check the value
    If Int(X / m_ButtonsWidth) >= m_ButtonsPerRow Or nIndex >= m_Button_Count Or nIndex < 0 Then
        nIndex = -1
        MousePointer = vbNormal
    Else
        If m_ButtonItem(nIndex).TB_Enabled = False Or m_ButtonItem(nIndex).TB_Type = TYP_Seperator Then
            nIndex = -1
            MousePointer = vbNormal
        Else
            MousePointer = vbCustom
        End If
    End If

    ' Redraw if necessary
    If Not nIndex = m_Button_Index Then
        m_Button_Index = nIndex
        RaiseEvent OnButtonHover(m_Button_Index)
        RedrawControl
    End If
    
Handle:
    RaiseEvent MouseMove(m_Button_Index, Button, Shift, X, Y)
    
End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    m_Pressed = False
    If Not m_Button_Index = -1 Then
        RedrawControl
        RaiseEvent MouseUp(m_Button_Index, Button, Shift, X, Y)
    End If
End Sub

'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    
    'debug.Print "Reading properties..."

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -