Instead of using user-defined-types and arrays, why not use object classes and collections?
Here is your cCursor class module:
VB Code:
Public Enum CursorAxes Vertical = 0 Horizontal = 1 End Enum Public Enum CursorStyle Major_X = 0 Major_XMinor_Y = 1 Major_Y = 2 Major_YMinor_X = 3 End Enum Private mintAxes As CursorAxes Private mblnCursorMovable As Boolean Private mintStyle As CursorStyle Private mblnCursorVisible As Boolean Public Property Get Axes() As CursorAxes Axes = mintAxes End Property Public Property Let Axes(intNewValue As CursorAxes) mintAxes = intNewValue End Property Public Property Get CursorMoveable() As Boolean CursorMoveable = mblnCursorMoveable End Property Public Property Let CursorMoveable(blnNewValue As Boolean) mblnCursorMoveable = blnNewValue End Property Public Property Get Style() As CursorStyles Style= mintStyles End Property Public Property Let Axes(intNewValue As CursorStyles) mintStyles= intNewValue End Property Public Property Get CursorVisible() As Boolean CursorVisible= mblnCursorVisible End Property Public Property Let CursorVisible(blnNewValue As Boolean) mblnCursorVisible = blnNewValue End Property
Here is your cCursors collection class module:
VB Code:
Private mcolCursors As Collection Public Function AddNew(Index) As cObj Dim cObj As cCursor Set cObj = New cCursor If Index > 0 Then mcolCursors .Add cCursor, , Index Else mcolCursors .Add cCursor End If Set AddNew = cObj End Function ' Set this property to default Public Function Item(Index) As cObj Set Item = mcolCursors.Item(Index) End Function Public Function Count() As Integer Count = mcolCursors.Count End Function Public Sub Clear() Set mcolCursors = New Collection End Sub Public Sub Remove(Index) mcolCursors.Remove Index End Sub Private Sub Class_Initialize() ' Instantiate collection Set mcolCursors = New Collection End Sub Private Sub Class_Terminate() Set mcolCursors = Nothing End Sub ' NewEnum must return the IUnknown interface of a ' collection's enumerator. ' NB: Set Procedure ID to -4 Public Function NewEnum() As IUnknown Set NewEnum = mcolWaypoints.[_NewEnum] End Function
No you can do things like:
VB Code:
Dim Cur As cCursor Dim cls As cCursors Set cls = New cCursors Set Cur = cls.AddNew() Cur.CursorMoveable = True Cur.CursorStyle = Major_YMinor_X cls(1).CursorAxes = Vertical





Reply With Quote