home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / vb5addin / dsaddin.cls < prev    next >
Text File  |  1998-04-02  |  3KB  |  77 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "DSAddIn"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Attribute VB_Description = "VB5-authored Add-in"
  11. Option Explicit
  12.  
  13. Dim m_cookie As Integer
  14. Dim m_Commands As Commands
  15.  
  16. Implements IDSAddIn
  17. Public Property Get Description()
  18. Attribute Description.VB_Description = "Illustrates a Developer Studio Add-in written with VB5"
  19.     ' TODO: Enter the description for this object in the Object Browser
  20.     '       (In the object browser, right-click this property and choose Properties)
  21.     '       The actual value of the Description property is unimportant.
  22.     Description = ""
  23. End Property
  24.  
  25. Private Function IDSAddIn_OnConnection(ByVal pApp As DSSharedObjects.IApplication, ByVal bFirstTime As Boolean, ByVal dwCookie As Long) As Boolean
  26.  
  27.     Set m_Commands = New Commands
  28.     
  29.     ' This stores the application & debugger objects in m_Commands.  Since
  30.     '  m_app & m_debugger are statically typed to be Application and Debugger, all
  31.     '  method and property accesses through them will use the dual interfaces of the
  32.     '  Developer Studio Application and Debugger objects
  33.     ' Since m_app & m_debugger are also declared "WithEvents", these assignments will
  34.     '  cause any event handlers in m_Commands to be connected to
  35.     '  the Developer Studio Application and Debugger events.
  36.     Set m_Commands.m_app = pApp
  37.     Set m_Commands.m_debugger = pApp.Debugger
  38.     
  39.     m_cookie = dwCookie
  40.     
  41.     Dim instance As Long
  42.     instance = App.hInstance
  43.     m_Commands.m_app.SetAddInInfo instance, m_Commands, 1, 2, dwCookie
  44.     
  45.     ' For each command in m_Commands class module, we add a command
  46.     '  to the DevStudio shell.  You may add new commands to m_Commands
  47.     '  by adding new public subs (make sure they have no return values and
  48.     '  or arguments), and then add them to the Developer Studio
  49.     '  commands by adding a corresponding call below.
  50.     ' The first argument is: CommandName (no spaces) & menu text &
  51.     '  status bar prompt & tooltip.  Then are the implementation method
  52.     '  name, toolbar button bitmap offset, and cookie.
  53.     m_Commands.m_app.AddCommand "Vb5AddInCommand" & Chr(10) _
  54.         & "Vb5AddIn Sample Command" & Chr(10) _
  55.         & "Displays a message box" & Chr(10) _
  56.         & "Vb5AddIn Command", _
  57.         "Vb5AddInCommand", 0, dwCookie
  58.         
  59.     ' Add toolbar buttons only if this is the first time the add-in
  60.     '  is being loaded.  Toolbar buttons are automatically remembered
  61.     '  by Developer Studio from session to session, so we should only
  62.     '  add the toolbar buttons once.
  63.     If bFirstTime = True Then
  64.         m_Commands.m_app.AddCommandBarButton dsGlyph, "Vb5AddInCommand", dwCookie
  65.     End If
  66.         
  67.     IDSAddIn_OnConnection = True
  68. End Function
  69.  
  70. Private Sub IDSAddIn_OnDisconnection(ByVal bLastTime As Boolean)
  71.     Set m_Commands.m_app = Nothing
  72.     Set m_Commands.m_debugger = Nothing
  73.     Set m_Commands = Nothing
  74. End Sub
  75.  
  76.  
  77.