home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / turbocad / v8trial / TurboCADv8ProfessionalNoReg.exe / Data.Cab / F41477_modGraphicCollections.bas < prev    next >
Encoding:
BASIC Source File  |  2001-10-16  |  3.8 KB  |  102 lines

  1. Attribute VB_Name = "modGraphicCollections"
  2. '******************************************************************'
  3. '*                                                                *'
  4. '*                      TurboCAD for Windows                      *'
  5. '*                   Copyright (c) 1993 - 2001                    *'
  6. '*             International Microcomputer Software, Inc.         *'
  7. '*                            (IMSI)                              *'
  8. '*                      All rights reserved.                      *'
  9. '*                                                                *'
  10. '******************************************************************'
  11.  
  12. Sub OwnershipEx1()
  13.     Dim gr As Graphic
  14.     
  15.     'Create standalone graphic
  16.     ActiveDrawing.Graphics.Clear
  17.     Debug.Print "Creating standalone graphic"
  18.     Set gr = New Graphic
  19.     'Zero graphics in drawing
  20.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  21.     'Parent is IApplication
  22.     Debug.Print "Parent type: " & TypeName(gr.Parent)
  23.     'Graphic is NOT in drawing -- it's standalone
  24.     Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
  25.     'Graphic will be destroyed
  26.     Set gr = Nothing
  27.     'Still zero graphics in drawing
  28.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  29. End Sub
  30.  
  31. Sub OwnershipEx2()
  32.     Dim gr As Graphic
  33.     
  34.     'Create owned graphic
  35.     ActiveDrawing.Graphics.Clear
  36.     Debug.Print "Adding graphic"
  37.     Set gr = ActiveDrawing.Graphics.Add
  38.     'One graphic in drawing now
  39.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  40.     'Parent is IGraphic -- bug?
  41.     Debug.Print "Parent type: " & TypeName(gr.Parent)
  42.     'Graphic is in drawing
  43.     Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
  44.     'Graphic will NOT be destroyed -- we just lost a reference to it
  45.     Set gr = Nothing
  46.     'Still one graphic in drawing
  47.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  48. End Sub
  49.  
  50. Sub OwnershipEx3()
  51.     Dim gr As Graphic
  52.     
  53.     'Create owned graphic
  54.     ActiveDrawing.Graphics.Clear
  55.     Debug.Print "Adding graphic"
  56.     Set gr = ActiveDrawing.Graphics.Add
  57.     'One graphic in drawing now
  58.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  59.     'Parent is IGraphic -- bug?
  60.     Debug.Print "Parent type: " & TypeName(gr.Parent)
  61.     'Graphic is in drawing
  62.     Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
  63.     'Delete owned graphic
  64.     Debug.Print "Deleting graphic"
  65.     gr.Delete
  66.     Set gr = Nothing
  67.     'Zero graphics in drawing now
  68.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  69. End Sub
  70.  
  71. Sub OwnershipEx4()
  72.     Dim gr As Graphic
  73.     Dim i As Integer
  74.     
  75.     'Create owned graphic
  76.     ActiveDrawing.Graphics.Clear
  77.     Debug.Print "Adding graphic"
  78.     Set gr = ActiveDrawing.Graphics.Add
  79.     'One graphic in drawing now
  80.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  81.     'Parent is IGraphic -- bug?
  82.     Debug.Print "Parent type: " & TypeName(gr.Parent)
  83.     'Graphic is in drawing
  84.     Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
  85.     'Get it's index for later and release our reference
  86.     i = gr.Index
  87.     Set gr = Nothing
  88.     
  89.     'Remove graphic from collection -- make it standalone
  90.     Debug.Print "Removing graphic from collection"
  91.     Set gr = ActiveDrawing.Graphics.Remove(i)
  92.     'Zero graphics in drawing now
  93.     Debug.Print "Now " & ActiveDrawing.Graphics.Count & " graphics in drawing"
  94.     'Parent is IGraphic -- bug?
  95.     Debug.Print "Parent type: " & TypeName(gr.Parent)
  96.     'Graphic is in drawing
  97.     Debug.Print "Graphic in drawing? " & (Not gr.Drawing Is Nothing)
  98.     'Release (and destroy) standalone
  99.     Set gr = Nothing
  100. End Sub
  101.  
  102.