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

📄 ctoolbar.cls

📁 人事档案管理系统(PB)/人事工资管理系统/干部信息管理系统/投标报价与合同管理系统/... 超市...
💻 CLS
字号:
VERSION 1.0 CLASS
Begin
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
End
Attribute VB_Name = "cToolbar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private WithEvents m_Toolbar As Toolbar
Attribute m_Toolbar.VB_VarHelpID = -1
Private mcol As Collection
Private m_iForm As iForm

Public Sub Attach(viForm As iForm, ByVal sKey As String)   
	On Error Resume Next
    mcol.Add viForm, sKey
    Activate sKey
End Sub

Public Sub Detach(ByVal sKey) 
	On Error Resume Next
    mcol.Remove sKey
    If mcol.Count = 1 Then
        Set m_iForm = mcol(1)
        RefreshVisibleState
        RefreshEnabledState
    End If
End Sub

Public Sub Activate(ByVal sKey As String) 
	On Error Resume Next
    Set m_iForm = mcol(sKey)
    RefreshVisibleState
    RefreshEnabledState
End Sub

Private Sub RefreshVisibleState()  
	On Error Resume Next
    Dim iState As ToolBarItems
    iState = m_iForm.Attributes
    With m_Toolbar
        .Buttons("New").Visible = iState And tbAddNew
        .Buttons("Save").Visible = iState And tbSave
        .Buttons("Cancel").Visible = iState And tbCancel
        .Buttons("Delete").Visible = iState And tbDel
        .Buttons("DeleteRow").Visible = iState And tbDeleteRow
        .Buttons("Refresh").Visible = iState And tbRefresh
        .Buttons("DBBar").Visible = iState And tbSave
        
        .Buttons("Print").Visible = iState And tbPrint
        .Buttons("Find").Visible = iState And tbFind
        .Buttons("FINDBar").Visible = iState And tbFind
        
        .Buttons("Form").Visible = iState And tbShowFormView
        .Buttons("FORMBar").Visible = iState And tbShowFormView
        
        .Buttons("Main").Visible = iState And tbMainMenu
        .Buttons("Help").Visible = iState And tbHelp
        .Buttons("Open").Visible = iState And tbOpen
        .Buttons("Close").Visible = iState And tbCloseMe
        .Buttons("CLOSEBar").Visible = iState And tbCloseMe
        
        If Not (m_iForm.FindSubTools Is Nothing) Then
            Dim i%
            With .Buttons("Find").ButtonMenus
                .Clear
                For i = 1 To m_iForm.FindSubTools.Count
                    .Add , m_iForm.FindSubTools.Item(i).csKey, _
                        m_iForm.FindSubTools.Item(i).csCaption
                Next
            End With
        End If
    End With
End Sub

Public Sub RefreshEnabledState()  
	On Error Resume Next
    Dim iState As ToolBarItems
    iState = m_iForm.EnableAttributes
    With m_Toolbar
        .Buttons("Save").Enabled = iState And tbSave
        .Buttons("Cancel").Enabled = iState And tbCancel
        .Buttons("Delete").Enabled = iState And tbDel
        .Buttons("Refresh").Enabled = iState And tbRefresh
        .Buttons("Find").Enabled = iState And tbFind
        .Buttons("Form").Enabled = iState And tbShowFormView
        .Buttons("New").Enabled = iState And tbAddNew
        .Buttons("Close").Enabled = iState And tbCloseMe
    End With
End Sub

Private Sub Class_Initialize()
    Set m_Toolbar = fMainForm.tlBar
    Set mcol = New Collection
End Sub

Private Sub m_Toolbar_ButtonClick(ByVal Button As MSComctlLib.Button)   
	On Error Resume Next
    Select Case Button.Key
        Case "New"
            m_iForm.AddNew
        Case "Close"
            m_iForm.CloseMe
        Case "Refresh"
            m_iForm.Refresh
        Case "Cancel"
            m_iForm.Cancel
        Case "Save"
            m_iForm.Save
        Case "Delete"
            m_iForm.delete
        Case "Form"
            m_iForm.ShowFormView
        Case "DeleteRow"
            m_iForm.DeleteRow
        Case "Main"
            m_iForm.MainMenu
        Case "Open"
            m_iForm.OpenDB
        Case "Print"
            m_iForm.PrintOut
        Case "Help"
            m_iForm.HelpAbout
    End Select
End Sub

Private Sub m_Toolbar_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)  
	On Error Resume Next
    m_iForm.Find ButtonMenu.Key
End Sub

⌨️ 快捷键说明

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