vbAccelerator - Contents of code file: cToolItem.cls

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "cToolItem"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

'
 ===============================================================================
=======
' Name:     cToolItem.cls
' Author:   Steve McMahon (steve@vbaccelerator.com)
' Date:     9 February 2003
'
' Requires: -
'
' Copyright  2003 Steve McMahon for vbAccelerator
'
 -------------------------------------------------------------------------------
-------
' Visit vbAccelerator - advanced free source code for VB programmers
'    http://vbaccelerator.com
'
 -------------------------------------------------------------------------------
-------
'
' Public access to tab properties for the vbalDTab6 control.
'
' FREE SOURCE CODE - ENJOY!
' Do not sell this code.  Credit vbAccelerator.
'
 ===============================================================================
=======

Private Declare Function IsWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As
 Any, pSrc As Any, ByVal ByteLen As Long)

Private m_lOwner As Long
Private m_hWnd As Long
Private m_lBarId As Long
Private m_lId As Long

Friend Sub fInit(ByVal lPtr As Long, ByVal lhWnd As Long, ByVal lBarId As Long,
 ByVal lItemId As Long)
   m_lOwner = lPtr
   m_hWnd = lhWnd
   m_lBarId = lBarId
   m_lId = lItemId
End Sub

Public Property Get OwnerControl() As vbalToolBoxBarCtl
Attribute OwnerControl.VB_Description = "Gets the owning control for this item."
   If Not (m_hWnd = 0) Then
      If (IsWindow(m_hWnd)) Then
         If Not (m_lOwner = 0) Then
            Dim oT As Object
            CopyMemory oT, m_lOwner, 4
            Set OwnerControl = oT
            CopyMemory oT, 0&, 4
            Exit Property
         End If
      End If
   End If
   Err.Raise 9, App.EXEName & ".vbalToolBoxBarCtl"
End Property

Public Sub EnsureVisible()
Attribute EnsureVisible.VB_Description = "Ensures the item can be seen on the
 screen."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemEnsureVisible m_lBarId, m_lId
   End If
End Sub

Public Property Get NextItem() As cToolItem
Attribute NextItem.VB_Description = "Gets the next item along in the bar."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Set NextItem = oT.fNextItem(m_lBarId, m_lId, 1)
   End If
End Property
Public Property Get PreviousItem() As cToolItem
Attribute PreviousItem.VB_Description = "Gets the previous item along from this
 item in the bar."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Set PreviousItem = oT.fNextItem(m_lBarId, m_lId, -1)
   End If
End Property

Public Sub MovePrevious()
Attribute MovePrevious.VB_Description = "Moves this item to the previous
 position along in the bar."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemMove m_lBarId, m_lId, -1
   End If
End Sub

Public Sub MoveNext()
Attribute MoveNext.VB_Description = "Moves this item to the next position along
 within the bar."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemMove m_lBarId, m_lId, 1
   End If
End Sub

Public Property Get Caption() As String
Attribute Caption.VB_Description = "Gets/sets the caption of this item."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Caption = oT.fItemCaption(m_lBarId, m_lId)
   End If
End Property
Public Property Let Caption(ByVal sCaption As String)
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemCaption(m_lBarId, m_lId) = sCaption
   End If
End Property

Public Property Get Tag() As String
Attribute Tag.VB_Description = "Gets/sets a string value associated with this
 item."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Tag = oT.fItemTag(m_lBarId, m_lId)
   End If
End Property
Public Property Let Tag(ByVal sTag As String)
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemTag(m_lBarId, m_lId) = sTag
   End If
End Property

Public Property Get ItemData() As Long
Attribute ItemData.VB_Description = "Gets/sets a long value associated with the
 item."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      ItemData = oT.fItemData(m_lBarId, m_lId)
   End If
End Property
Public Property Let ItemData(ByVal lItemData As Long)
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemData(m_lBarId, m_lId) = lItemData
   End If
End Property

Public Property Get Key() As String
Attribute Key.VB_Description = "Gets the key of this item."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Key = oT.fItemKey(m_lBarId, m_lId)
   End If
End Property

Public Property Get Index() As Long
Attribute Index.VB_Description = "Gets the index of this item within its bar."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Index = oT.fItemIndex(m_lBarId, m_lId)
   End If
End Property

Public Property Get Selected() As Boolean
Attribute Selected.VB_Description = "Gets/sets whether this item is selected or
 not."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Selected = oT.fItemSelected(m_lBarId, m_lId)
   End If
End Property
Public Property Let Selected(ByVal bSelected As Boolean)
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemSelected(m_lBarId, m_lId) = bSelected
   End If
End Property

Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "Gets/sets whether this item is enabled or
 not."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Enabled = oT.fItemEnabled(m_lBarId, m_lId)
   End If
End Property
Public Property Let Enabled(ByVal bEnabled As Boolean)
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemEnabled(m_lBarId, m_lId) = bEnabled
   End If
End Property

Public Property Get CanDrag() As Boolean
Attribute CanDrag.VB_Description = "Gets/sets whether this item can be dragged.
 Defaults to True."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      CanDrag = oT.fItemCanDrag(m_lBarId, m_lId)
   End If
End Property
Public Property Let CanDrag(ByVal bCanDrag As Boolean)
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      oT.fItemCanDrag(m_lBarId, m_lId) = bCanDrag
   End If
End Property

Public Property Get OwnerBar() As cToolBoxBar
Attribute OwnerBar.VB_Description = "Gets the owning bar for this item."
Dim oT As vbalToolBoxBarCtl
   Set oT = OwnerControl()
   If Not oT Is Nothing Then
      Dim lBarIndex As Long
      lBarIndex = oT.fBarIndex(m_lBarId)
      If (lBarIndex > 0) Then
         Set OwnerBar = oT.fBarItem(lBarIndex)
      End If
   End If
End Property

Private Sub Class_Initialize()
   'Debug.Print "cToolItem:Initialize", ObjPtr(Me)
End Sub

Private Sub Class_Terminate()
   'Debug.Print "cToolItem:Terminate", ObjPtr(Me)
End Sub