C++
  Home arrow C++ arrow Page 3 - Building An Outlook COM Add-In With VC /A...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C++

Building An Outlook COM Add-In With VC /ATL
By: Amit Dey
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 57
    2002-02-17

    Table of Contents:
  • Building An Outlook COM Add-In With VC /ATL
  • Getting started
  • Building a minimal COM add-in
  • Command and conquer
  • Command and conquer (contd.)
  • Lord of the (disp) sinks
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building An Outlook COM Add-In With VC /ATL - Building a minimal COM add-in


    (Page 3 of 7 )

    We now know enough to go ahead and code up a minimal Outlook 2000 COM add-in. To build the add-in project files, fire up the Visual C++ IDE, create a new ATL COM App Wizard project, and name it "OutlookAddin".

    In the Appwizard Step 1 of 1 dialog that follows, accept the default Server Type, Dynamic Link Library(DLL). Enable the "Allow merging of proxy-stub code" option and click finish. Click OK to generate the project files.

    Click on the Insert -> New ATL Object menu item and insert a new ATL simple object into our project by choosing objects from category, and simple object from the objects list in the ATL object wizard dialog. Click next and type addin as the value of short name. In the attributes tab, check the support IsupportErrorInfo check box. Accept the default options for all of the other options, and click OK.

    So far the wizard has given us an automation-compatible, dispinterface-savvy in process COM object housed in a DLL. A registry script (.rgs) to add the COM object specific registry entries has also been created for us. Build the project and make sure everything is in order (at this point you may also like to compile your projects .idl file).

    We will now write our add-in specific code to implement the IDTExtensibility2 interface.This is where we let the implement interface ATL wizard kick in and make our life a lot easier. In class view, right-click on the CAddin class and choose implement interface. This brings up the ATL implement interface wizard. Click on add typelib, and in the browse type libraries dialog scroll down and check microsoft add-in designer (1.0). Click OK. Next, check the _IDTExtensibility2 interface from the list under the add-in designer objects tab of the implement interface dialog and click OK.

    The wizard implements the selected interface for us by adding a default implementation for each of the five methods of the _IDTExtensibility2 interface to the CAddin class, and also updates the COM_INTERFACE_MAP() block. Each of the methods just returns E_NOTIMPL of course, and it's up to us to add the code so that they do something useful. For now however, our COM add-in is ready, except the for the necessary registry entries, which we will add next.

    To register our add-in with the host application (in our case Outlook 2000), open the project's addin.rgs registry script file (located under File View -> Resource Files) and add the following text to the end of the file:

    HKCU

    {

    Software

    {

    Microsoft

    {

    Office

    {

    Outlook

    {

    Addins

    {

    'OutlookAddin.Addin'

    {

    val FriendlyName = s 'ADOutlook2K Addin'

    val Description = s 'ATLCOM Outlook Addin'

    val LoadBehavior = d '00000008'

    val CommandLineSafe = d '00000000'

    }

    }

    }

    }

    }

    }

    }


    Since we want our add-in to load at startup, LoadBehavior is set to 3.Now build the project. If everything is in order, the project gets built successfully and registers the add-in. To test the add-in, either run the project and specify the full path to Outlook 2000 (c:\Program Files\Microsoft Office\Office\Outlook.exe) as the value for "executable for debug session", or run Outlook 2000 outside of the Visual C++ IDE after you have registered the DLL. To check if our add-in has been registered successfully in Outlook, go to Tools -> Options. Under the "Other" tab, click Advanced Options -> COM Add-ins. An entry for our COM add-in should have been added to the add-ins available list; the string displayed is the value that we specified as 'FriendlyName' in our registry script:

    Our add-in as displayed in Outlook 2000

    While an addin can be programmed for different uses, there are certain tasks that will be common to everyone. Typically, they include adding user-interface elements like toolbars/tool bands and menu items to Outlook, through which the user can control the add-in.By clicking on these buttons and menu items, the user can access the add-in's functionality. Let's tackle such toolbar and menu item additions now.

    More C++ Articles
    More By Amit Dey


     

    C++ ARTICLES

    - More Tricks to Gain Speed in Programming Con...
    - Easy and Efficient Programming for Contests
    - Preparing For Programming Contests
    - Programming Contests: Why Bother?
    - Polymorphism in C++
    - Overview of Virtual Functions
    - Inheritance in C++
    - Extending the Basic Streams in C++
    - Using Stringstreams in C++
    - Custom Stream Manipulation in C++
    - General Stream Manipulation in C++
    - Serialize Your Class into Streams in C++
    - Advanced File Handling with Streams in C++
    - File Handling and Streams in C++
    - The STL String Class







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek