home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "modGraphicCollections"
- '******************************************************************'
- '* *'
- '* TurboCAD for Windows *'
- '* Copyright (c) 1993 - 2001 *'
- '* International Microcomputer Software, Inc. *'
- '* (IMSI) *'
- '* All rights reserved. *'
- '* *'
- '******************************************************************'
-
- Sub OwnershipEx1()
- Dim gr As Graphic
-
- 'Create standalone graphic
- ActiveDrawing.Graphics.Clear
- Debug.Print "Creating standalone graphic"
- Set gr = New Graphic
- 'Zero graphics in drawing
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- 'Parent is IApplication
- Debug.Print "Parent type: " & TypeName(gr.Parent)
- 'Graphic is NOT in drawing -- it's standalone
- Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
- 'Graphic will be destroyed
- Set gr = Nothing
- 'Still zero graphics in drawing
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- End Sub
-
- Sub OwnershipEx2()
- Dim gr As Graphic
-
- 'Create owned graphic
- ActiveDrawing.Graphics.Clear
- Debug.Print "Adding graphic"
- Set gr = ActiveDrawing.Graphics.Add
- 'One graphic in drawing now
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- 'Parent is IGraphic -- bug?
- Debug.Print "Parent type: " & TypeName(gr.Parent)
- 'Graphic is in drawing
- Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
- 'Graphic will NOT be destroyed -- we just lost a reference to it
- Set gr = Nothing
- 'Still one graphic in drawing
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- End Sub
-
- Sub OwnershipEx3()
- Dim gr As Graphic
-
- 'Create owned graphic
- ActiveDrawing.Graphics.Clear
- Debug.Print "Adding graphic"
- Set gr = ActiveDrawing.Graphics.Add
- 'One graphic in drawing now
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- 'Parent is IGraphic -- bug?
- Debug.Print "Parent type: " & TypeName(gr.Parent)
- 'Graphic is in drawing
- Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
- 'Delete owned graphic
- Debug.Print "Deleting graphic"
- gr.Delete
- Set gr = Nothing
- 'Zero graphics in drawing now
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- End Sub
-
- Sub OwnershipEx4()
- Dim gr As Graphic
- Dim i As Integer
-
- 'Create owned graphic
- ActiveDrawing.Graphics.Clear
- Debug.Print "Adding graphic"
- Set gr = ActiveDrawing.Graphics.Add
- 'One graphic in drawing now
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- 'Parent is IGraphic -- bug?
- Debug.Print "Parent type: " & TypeName(gr.Parent)
- 'Graphic is in drawing
- Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
- 'Get it's index for later and release our reference
- i = gr.Index
- Set gr = Nothing
-
- 'Remove graphic from collection -- make it standalone
- Debug.Print "Removing graphic from collection"
- Set gr = ActiveDrawing.Graphics.Remove(i)
- 'Zero graphics in drawing now
- Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
- 'Parent is IGraphic -- bug?
- Debug.Print "Parent type: " & TypeName(gr.Parent)
- 'Graphic is in drawing
- Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
- 'Release (and destroy) standalone
- Set gr = Nothing
- End Sub
-
-