home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / spy.cls < prev    next >
Encoding:
Text File  |  1995-07-26  |  1.7 KB  |  53 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "FileEventSpy"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. Attribute VB_Description = "File Event Spy Sample Addin"
  9. 'Place to keep our instance of the VBInstance object that was passed to us in
  10. 'ConnectAddIn.
  11. Private ThisInstance As VBIDE.Application
  12.  
  13. 'Place to keep the menuline object given to us when we installed out menu line
  14. 'in Visual Basic.
  15. Private SpyMenuLine As VBIDE.MenuLine
  16.  
  17. 'Make our instance of the event handler object.
  18. Private SpyHandler As New SpyEvents
  19.  
  20. 'Place to store the connect cookies that are handed to us.
  21. Private FileEventID As Long
  22. Private AfterClickID As Long
  23.  
  24.  
  25. Sub ConnectAddIn(VBInstance As VBIDE.Application)
  26.     'Stash away our copy of VBInstance, so we can disconnect from the right
  27.     'instance of Visual Basic
  28.     Set ThisInstance = VBInstance
  29.     
  30.     'Install our menu line in Visual Basic's Add-In menu
  31.     Set SpyMenuLine = ThisInstance.AddInMenu.MenuItems.Add("File Event Spy")
  32.     
  33.     'Pass our event handler the MenuLine.
  34.     Set SpyHandler.SpyMenuLine = SpyMenuLine
  35.     
  36.     'Connect in our event handler to the menu line
  37.     AfterClickID = SpyMenuLine.ConnectEvents(SpyHandler)
  38.     
  39.     'Let SpyHandler Check the menu line.
  40.     SpyHandler.AfterClick
  41.     
  42.     'Connect our event handler to the FileControl object
  43.     FileEventID = ThisInstance.FileControl.ConnectEvents(SpyHandler)
  44. End Sub
  45.  
  46. Sub DisconnectAddIn(Mode As Integer)
  47.     SpyMenuLine.DisconnectEvents AfterClickID
  48.     With ThisInstance
  49.         .FileControl.DisconnectEvents FileEventID
  50.         .AddInMenu.MenuItems.Remove SpyMenuLine
  51.     End With
  52. End Sub
  53.