vbAccelerator - Contents of code file: mfrmMain.frm

VERSION 5.00
Object = "{74AB545E-1F51-4CA8-A61B-89925A0B8D2A}#1.5#0"; "vbalDTab.ocx"
Object = "{896EE2E8-B1A5-475E-855E-A5E4531DF26E}#2.4#0"; "vbalToolboxBar.ocx"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.MDIForm mfrmMain 
   BackColor       =   &H8000000C&
   Caption         =   "vbAccelerator Clipboard Ring Demonstration"
   ClientHeight    =   3405
   ClientLeft      =   4020
   ClientTop       =   3885
   ClientWidth     =   6225
   Icon            =   "mfrmMain.frx":0000
   LinkTopic       =   "MDIForm1"
   Begin vbalDTab.vbalDTabControl tabTools 
      Align           =   3  'Align Left
      Height          =   3405
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   360
      _ExtentX        =   635
      _ExtentY        =   6006
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty SelectedFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Pinnable        =   -1  'True
      Pinned          =   0   'False
      Begin vbalToolboxBarLib.vbalToolBoxBarCtl tbxClipboard 
         Height          =   6135
         Left            =   300
         TabIndex        =   1
         Top             =   720
         Width           =   2115
         _ExtentX        =   3731
         _ExtentY        =   10821
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
   End
   Begin ComctlLib.ImageList ilsIcons 
      Left            =   780
      Top             =   60
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483633
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   327682
      BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
         NumListImages   =   3
         BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "mfrmMain.frx":1272
            Key             =   "TOOLBOX"
         EndProperty
         BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "mfrmMain.frx":13CC
            Key             =   "POINTER"
         EndProperty
         BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "mfrmMain.frx":1526
            Key             =   "TEXT"
         EndProperty
      EndProperty
   End
   Begin VB.Menu mnuFileTOP 
      Caption         =   "&File"
      Begin VB.Menu mnuFile 
         Caption         =   "&New..."
         Index           =   0
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuFile 
         Caption         =   "-"
         Index           =   1
      End
      Begin VB.Menu mnuFile 
         Caption         =   "&Open..."
         Index           =   2
         Shortcut        =   ^O
      End
      Begin VB.Menu mnuFile 
         Caption         =   "&Save"
         Index           =   3
         Shortcut        =   ^S
      End
      Begin VB.Menu mnuFile 
         Caption         =   "Save &As"
         Index           =   4
      End
      Begin VB.Menu mnuFile 
         Caption         =   "-"
         Index           =   5
      End
      Begin VB.Menu mnuFile 
         Caption         =   "E&xit"
         Index           =   6
      End
   End
   Begin VB.Menu mnuHelpTOP 
      Caption         =   "&Help"
      Begin VB.Menu mnuHelpAbout 
         Caption         =   "&About..."
         Index           =   0
      End
   End
End
Attribute VB_Name = "mfrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private WithEvents m_cClipView As cClipboardViewer
Attribute m_cClipView.VB_VarHelpID = -1
Private WithEvents m_cMdiTabs As cMDITabs
Attribute m_cMdiTabs.VB_VarHelpID = -1

Private m_lId As Long
Private m_lDocId As Long

Private Sub m_cClipView_ClipboardChanged()
   If (Clipboard.GetFormat(vbCFText)) Then
      m_lId = m_lId + 1
      Dim itmX As cToolItem
      Set itmX = tbxClipboard.Bars(1).Items.Add("C" & m_lId, ,
       Clipboard.GetText, ilsIcons.ListImages("TEXT").Index - 1)
      If (tbxClipboard.Bars(1).Items.Count > 101) Then
         ' limit to 100 entries:
         tbxClipboard.Bars(1).Items.Remove "C" & m_lId - 100
      End If
      itmX.Selected = True
   End If
End Sub


Private Sub m_cMdiTabs_CloseWindow(ByVal hwnd As Long)
   ' check whether ok to close, and then close
End Sub

Private Sub MDIForm_Load()

   Set m_cMdiTabs = New cMDITabs
   m_cMdiTabs.Attach Me.hwnd

   Dim tbr As cToolBoxBar
   tbxClipboard.ImageList = ilsIcons
   Set tbr = tbxClipboard.Bars.Add("CLIPBOARD", , "Clipboard Ring")
   Dim itmX As cToolItem
   Set itmX = tbr.Items.Add("C" & m_lId, , "Pointer",
    ilsIcons.ListImages("POINTER").Index - 1)
   itmX.CanDrag = False

   Dim tabX As cTab
   tabTools.ImageList = ilsIcons
   tabTools.ShowTabs = False
   Set tabX = tabTools.Tabs.Add("TOOLS", , "Tools",
    ilsIcons.ListImages("TOOLBOX").Index - 1)
   tabX.Panel = tbxClipboard
   tabX.CanClose = False
   
   Set m_cClipView = New cClipboardViewer
   m_cClipView.InitClipboardChangeNotification Me.hwnd
   
   ' Perform New Action
   mnuFile_Click 0
   
End Sub

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   m_cClipView.StopClipboardChangeNotification
End Sub

Private Sub mnuFile_Click(Index As Integer)
Dim f As frmDocument
   
   Select Case Index
   Case 0
      Set f = New frmDocument
      m_lDocId = m_lDocId + 1
      f.FilePath = "Document" & m_lDocId & ".txt"
      f.Show
      m_cMdiTabs.ForceRefresh

   Case 2
      ' Open
      Set f = New frmDocument
      If Not (f.OpenFile("")) Then
         Unload f
      End If
      f.Show
      m_cMdiTabs.ForceRefresh
      
   Case 3
      ' Save
      If Not Me.ActiveForm Is Nothing Then
         If Not Me.ActiveForm Is Me Then
            Me.ActiveForm.Save
         End If
      End If
      
   Case 4
      ' Save As
      If Not Me.ActiveForm Is Nothing Then
         If Not Me.ActiveForm Is Me Then
            Me.ActiveForm.SaveAs
         End If
      End If
      
   Case 6
      ' exit
      Unload Me

   End Select
   
End Sub

Private Sub mnuHelpAbout_Click(Index As Integer)
   Select Case Index
   Case 0
      Dim f As New frmAbout
      f.Show vbModal, Me
   End Select
End Sub

Private Sub tbxClipboard_ItemDblClick(Item As cToolItem, ByVal Button As
 MouseButtonConstants, ByVal Shift As ShiftConstants, ByVal x As Single, ByVal
 y As Single)
   If Not Item Is Nothing Then
      If Not Me.ActiveForm Is Nothing Then
         If Not Me.ActiveForm Is Me Then
            Me.ActiveForm.AddText tbxClipboard.SelectedBar.SelectedItem.Caption
            tabTools.Shown = False
         End If
      End If
   End If
End Sub

Private Sub tbxClipboard_ItemSelected(Item As vbalToolboxBarLib.cToolItem)
   tabTools.SetFocus
   tbxClipboard.SetFocus
End Sub

Private Sub tbxClipboard_KeyPress(KeyAscii As Integer)
   If (KeyAscii = vbKeyReturn) Then
      If Not Me.ActiveForm Is Nothing Then
         If Not Me.ActiveForm Is Me Then
            Me.ActiveForm.AddText tbxClipboard.SelectedBar.SelectedItem.Caption
            tabTools.Shown = False
         End If
      End If
   End If
End Sub