Results 1 to 2 of 2

Thread: Active X Get/Let

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796
    Instead of using user-defined-types and arrays, why not use object classes and collections?

    Here is your cCursor class module:
    VB Code:
    1. Public Enum CursorAxes
    2.     Vertical = 0
    3.     Horizontal = 1
    4. End Enum
    5.  
    6. Public Enum CursorStyle
    7.     Major_X = 0
    8.     Major_XMinor_Y = 1
    9.     Major_Y = 2
    10.     Major_YMinor_X = 3
    11. End Enum
    12.  
    13. Private mintAxes As CursorAxes
    14. Private mblnCursorMovable As Boolean
    15. Private mintStyle As CursorStyle
    16. Private mblnCursorVisible As Boolean
    17.  
    18. Public Property Get Axes() As CursorAxes
    19.     Axes = mintAxes
    20. End Property
    21.  
    22. Public Property Let Axes(intNewValue As CursorAxes)
    23.     mintAxes = intNewValue
    24. End Property
    25.  
    26. Public Property Get CursorMoveable() As Boolean
    27.     CursorMoveable = mblnCursorMoveable
    28. End Property
    29.  
    30. Public Property Let CursorMoveable(blnNewValue As Boolean)
    31.     mblnCursorMoveable = blnNewValue
    32. End Property
    33.  
    34. Public Property Get Style() As CursorStyles
    35.     Style= mintStyles
    36. End Property
    37.  
    38. Public Property Let Axes(intNewValue As CursorStyles)
    39.     mintStyles= intNewValue
    40. End Property
    41.  
    42. Public Property Get CursorVisible() As Boolean
    43.     CursorVisible= mblnCursorVisible
    44. End Property
    45.  
    46. Public Property Let CursorVisible(blnNewValue As Boolean)
    47.     mblnCursorVisible = blnNewValue
    48. End Property

    Here is your cCursors collection class module:
    VB Code:
    1. Private mcolCursors As Collection
    2.  
    3. Public Function AddNew(Index) As cObj
    4.     Dim cObj As cCursor
    5.    
    6.     Set cObj = New cCursor
    7.     If Index > 0 Then
    8.         mcolCursors .Add cCursor, , Index
    9.     Else
    10.         mcolCursors .Add cCursor
    11.     End If
    12.     Set AddNew = cObj
    13. End Function
    14.  
    15. ' Set this property to default
    16. Public Function Item(Index) As cObj
    17.     Set Item = mcolCursors.Item(Index)
    18. End Function
    19.  
    20. Public Function Count() As Integer
    21.     Count = mcolCursors.Count
    22. End Function
    23.  
    24. Public Sub Clear()
    25.     Set mcolCursors = New Collection
    26. End Sub
    27.  
    28. Public Sub Remove(Index)
    29.     mcolCursors.Remove Index
    30. End Sub
    31.  
    32. Private Sub Class_Initialize()
    33.     ' Instantiate collection
    34.     Set mcolCursors = New Collection
    35. End Sub
    36.  
    37. Private Sub Class_Terminate()
    38.     Set mcolCursors = Nothing
    39. End Sub
    40.  
    41. ' NewEnum must return the IUnknown interface of a
    42. ' collection's enumerator.
    43. ' NB: Set Procedure ID to -4
    44. Public Function NewEnum() As IUnknown
    45.    Set NewEnum = mcolWaypoints.[_NewEnum]
    46. End Function

    No you can do things like:
    VB Code:
    1. Dim Cur As cCursor
    2. Dim cls As cCursors
    3.  
    4. Set cls = New cCursors
    5. Set Cur = cls.AddNew()
    6. Cur.CursorMoveable = True
    7. Cur.CursorStyle = Major_YMinor_X
    8.  
    9. cls(1).CursorAxes = Vertical
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    New Member
    Join Date
    Feb 2002
    Location
    New York
    Posts
    1
    Thanks,
    Used Class add-in to create, but was getting errors due to being in an Active X until I changed it to Global Multi-use.

    Thanks again for getting me on Track.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width