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

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