cListMove.cls
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:5k
源码类别:
浏览器
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "cListMove"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- '---------------------------------------------------------------------------------------
- ' Module : cListMove
- ' DateTime : 2005-3-14 20:54
- ' Author : Lingll
- ' Purpose :
- ' 2005-5-29 : fix ListCheck
- '---------------------------------------------------------------------------------------
- Option Explicit
- Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
- Private WithEvents m_List As ListBox
- Attribute m_List.VB_VarHelpID = -1
- Private WithEvents m_CmdUp As CommandButton
- Attribute m_CmdUp.VB_VarHelpID = -1
- Private WithEvents m_CmdDown As CommandButton
- Attribute m_CmdDown.VB_VarHelpID = -1
- Private WithEvents m_CmdAdd As CommandButton
- Attribute m_CmdAdd.VB_VarHelpID = -1
- Private WithEvents m_CmdDel As CommandButton
- Attribute m_CmdDel.VB_VarHelpID = -1
- Public Event ListClick(index&)
- Public Event ListCheck(ByVal index&, vChecked As Boolean)
- Public Event MoveUp(iUp&, iDown&, ByRef ptUp&, ByRef ptDown&, ByRef lenData&)
- Public Event MoveDown(iUp&, iDown&, ByRef ptUp&, ByRef ptDown&, ByRef lenData&)
- Public Event AddItem(ByRef Cancel As Boolean, ByRef newData$)
- Public Event AddItemAfter()
- Public Event DelItem(ByRef Cancel As Boolean, vIndex&)
- Public Event DelItemAfter()
- Public Sub IniMe(vList As ListBox, _
- vUp As CommandButton, vDown As CommandButton, _
- vAdd As CommandButton, vDel As CommandButton)
- Set m_List = vList
- Set m_CmdUp = vUp
- Set m_CmdDown = vDown
- Set m_CmdAdd = vAdd
- Set m_CmdDel = vDel
- End Sub
- Public Function GetListIndex() As Long
- If m_List.ListIndex > 0 Then
- GetListIndex = m_List.ListIndex
- Else
- GetListIndex = -1
- End If
- End Function
- Private Sub m_CmdAdd_Click()
- Dim tCancel As Boolean, tNewData$
- tCancel = False
- tNewData = "New Item"
- RaiseEvent AddItem(tCancel, tNewData)
- If tCancel Then
- Else
- m_List.AddItem tNewData
- m_List.ListIndex = m_List.ListCount - 1
- If m_List.Style = 1 Then
- RaiseEvent ListClick(m_List.ListIndex)
- End If
- RaiseEvent AddItemAfter
- End If
- End Sub
- Private Sub SwapData(vPt1&, vPt2&, vLen&)
- Dim tArr() As Byte
- If vPt1 <> 0 And vPt2 <> 0 And vLen <> 0 Then
- ReDim tArr(0 To vLen - 1)
- CopyMemory ByVal VarPtr(tArr(0)), ByVal vPt1, vLen
- CopyMemory ByVal vPt1, ByVal vPt2, vLen
- CopyMemory ByVal vPt2, ByVal VarPtr(tArr(0)), vLen
- End If
- End Sub
- Private Sub m_CmdDel_Click()
- Dim tIndex&, tCancel As Boolean
- tIndex = m_List.ListIndex
- If tIndex >= 0 Then
- tCancel = False
- RaiseEvent DelItem(tCancel, tIndex)
- If tCancel Then
- Else
- m_List.RemoveItem (tIndex)
- If tIndex > m_List.ListCount - 1 Then
- tIndex = tIndex - 1
- End If
- m_List.ListIndex = tIndex
- If m_List.Style = 1 Then
- RaiseEvent ListClick(tIndex)
- End If
- RaiseEvent DelItemAfter
- End If
- End If
- End Sub
- Private Sub m_CmdDown_Click()
- Dim tIndex&, tstr$
- Dim tPtUp&, tPtDown&, tLen&
- tIndex = m_List.ListIndex
- If tIndex < m_List.ListCount - 1 And tIndex >= 0 Then
- tstr = m_List.List(tIndex)
- m_List.List(tIndex) = m_List.List(tIndex + 1)
- m_List.List(tIndex + 1) = tstr
- RaiseEvent MoveDown(tIndex, tIndex + 1, tPtUp, tPtDown, tLen)
- Debug.Print tPtUp, tPtDown, tLen
- If tPtUp <> 0 And tPtDown <> 0 And tLen <> 0 Then
- Call SwapData(tPtUp, tPtDown, tLen)
- End If
- m_List.ListIndex = tIndex + 1
- End If
- End Sub
- Private Sub m_CmdUp_Click()
- Dim tIndex&, tstr$
- Dim tPtUp&, tPtDown&, tLen&
- tIndex = m_List.ListIndex
- If tIndex > 0 Then
- tstr = m_List.List(tIndex)
- m_List.List(tIndex) = m_List.List(tIndex - 1)
- m_List.List(tIndex - 1) = tstr
- RaiseEvent MoveUp(tIndex - 1, tIndex, tPtUp, tPtDown, tLen)
- If tPtUp <> 0 And tPtDown <> 0 And tLen <> 0 Then
- Call SwapData(tPtUp, tPtDown, tLen)
- End If
- m_List.ListIndex = tIndex - 1
- End If
- End Sub
- Private Sub m_List_Click()
- If m_List.ListIndex >= 0 Then
- RaiseEvent ListClick(m_List.ListIndex)
- End If
- End Sub
- Private Sub m_List_ItemCheck(Item As Integer)
- If m_List.ListCount > 0 Then
- RaiseEvent ListCheck(Item, m_List.Selected(Item))
- End If
- End Sub