Click here to Skip to main content
14,163,580 members
Click here to Skip to main content
Add your own
alternative version


95 bookmarked
Posted 2 Dec 2004

ATL COM Based Addin / Plugin Framework With Dynamic Toolbars and Menus

, 9 Dec 2004
Rate this:
Please Sign up or sign in to vote.
An article on ATL COM Based Addin / Plugin Framework With Dynamic Toolbars and Menus, based on VC++ Addin Architecture.



Building a product which suits to every customers requirement is every Companies dream. But in practice this may not be the case. This is because in most of the cases the requirement keep on changing drastically so that we have to make changes in the code level , recompile it, test it and ship it as another version. This way of development is not efficient in terms of project cost and developmental effort. This is where the Addin / Plugin architecture wins. In this article I have written a ATL COM Addin / Plugin Framework with dynamic toolbars and menu support . This framework is actually based on the VC++ 6.0 Addin Architecture which Microsoft used in every MS Office based applications (not sure of the exact implementation , just a guess work, because I followed the same path of VC++ Addin wizard generated code ). One difference, instead of adding menus , their description and other details in a new line delimited fashion in VC++ Addin , I used XML format for adding the Plugin details (Don't know why Microsoft didn't use XML?, perhaps at that time XML was not standardized , or is there any other specific reason??) along with Component Category for categorizing the plugins. Click here for seeing the XML format which I used in this project. You can add more properties as leaf nodes if you want (I followed the Idea of putting menu properties as nodes. Alternatively you can put the properties in some other fashion too).


This article assumes that you have a basic understanding of COM and MFC. This article is actually a continuation of the excellent article written by Zac Howland Pluggable Components using Component Categories - Part 1 . So the user is advised to go through this article first before coming to my article.

Using the code

The demo project attached contains 3 project workspaces written in VC++ 6.0. The application ProjectFramework is the one which loads all the addins , their menus, toolbars and other details. This application uses one core class called CAddinManager for various addin manipulations. The main header file of CAddinManager class is given below.

class CAddinManager 
    BOOL m_bLoadAllAdins;
    CArray<CAddinInfo,CAddinInfo> m_AddinInfoArray;
    CComPtr<IProjectFramework> m_ProjectFrameworkObject;
    HRESULT LoadAllAdins(BSTR strAddinLoadingInfo,
                         IProjectFramework* pProjectFramework);
    BOOL InvokeAddinMenuItem(UINT iCommandID);
    BOOL SetAddinVisible(CString strAddinName, BOOL bVisible);
    const CAddinInfo& GetAddinInformation(UINT iCommandID);
    const CAddinCommadInfo& GetAddinCommadInfo(UINT iCommandID);
    CAddinCommadInfo GetAddinCommadInfo(long iAddinIndex,long lIndex);
    BOOL AddAddinCommandInfo(long iAddinIndex, 
                             CAddinCommadInfo AddinCommadInfo);
    BOOL SetAddinCount(long lCount);
    BOOL UnloadAllAddins();
    CAddinInfo GetAddinInfo(long iAddinIndex);
    BOOL SetAddinInfo(long iAddinIndex,CAddinInfo AddinInfo);
    long GetAddinCount();
    void SetLoadAllAddinStatus(BOOL bLoadAllAddins);
    virtual BOOL GetLoadAllAddinStatus();
    CAddinInfo GetAddinIffo(CLSID clsID);

    BOOL LoadAllAddins();
    BOOL SaveAddinDefaultSettings();
    BOOL LoadAddinDefaultSettings();
    virtual ~CAddinManager();

This class uses a lot of other related classes like CAddinInfo which contains information's about each addin, IProjectFramework which is the interface exposed by the ProjectFramework application and IProjectFrameworkAddin interface which every pluggin should implement. Please see the source code for more details.The important blocks of codes in which the application built up is given below.

In CProjectFrameworkApp declare a variable of CAddinManager statically.

static CAddinManager m_AddinManager;
static CProjectFrameworkView* m_pView;


BOOL CProjectFrameworkApp::InitInstance()
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;

in CMainFrame






int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    //Load all addins

    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | 
                                         WS_VISIBLE | CBRS_TOP
                    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY 
                     | CBRS_SIZE_DYNAMIC) 
        || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
        TRACE0("Failed to create toolbar\n");
        return -1; // fail to create

    if (!m_wndStatusBar.Create(this) ||
        TRACE0("Failed to create status bar\n");
        return -1; // fail to create

    // TODO: Delete these three lines if you don't want the toolbar to
    // be dockable


    //Remove File new and Open Commands
    return 0;

Points of Interest

In this version features implemented are.

  1. Dynamic Menus.
  2. Dynamic Toolbars.
  3. Help string and tool tip support.
  4. Invoking of methods in plugins from addin menu and toolbar.
  5. Automation support explained using a dialog box invoked from one of the plugins (Report Addin -> Sales report -> Todays Sales Report Ctrl + B menu ).
  6. Hiding of Menus and toolbar buttons (eg : File ->New and Open ).
  7. Key Board accelerator support for plugin.
  8. Loading / Unloading of addins.
  9. Connection point support for getting notification events from addins.


  • Initial Release : Dec 2, 2004
  • Added Connection Point support : Dec 10, 2004


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Chief Technology Officer KTS INFOTECH PVT LTD
India India
->9+ Years of Experience in IT Field.
->Basically a C++ Programmer migrating to .NET
->Have Masters degree in Physics and Computer Scince.
-> Doing his Ph.D(Part Time) in Optical Networking)
->Interests: Software product development,Networking, Robotics,Sports Physics, Learning musical instruments, Cricket.

->Resides in kerala ,the gods own country, with his mother and wife.

Home page

You may also be interested in...

Comments and Discussions

QuestionHow can I merge the Menu to the ChildFrame? Pin
HarveyLiu2-Aug-05 22:49
memberHarveyLiu2-Aug-05 22:49 
AnswerRe: How can I merge the Menu to the ChildFrame? Pin
thomas_tom993-Aug-05 19:41
memberthomas_tom993-Aug-05 19:41 
GeneralRe: How can I merge the Menu to the ChildFrame? Pin
HarveyLiu3-Aug-05 22:23
memberHarveyLiu3-Aug-05 22:23 
GeneralRe: How can I merge the Menu to the ChildFrame? Pin
thomas_tom994-Aug-05 0:42
memberthomas_tom994-Aug-05 0:42 
GeneralThank you very much ! Pin
vark331-Jan-05 1:27
membervark331-Jan-05 1:27 
Questionaddinmanager.h(89): error C4716: 'CAddinCommadInfo::operator=' is ??? Pin
vark330-Jan-05 21:37
membervark330-Jan-05 21:37 
AnswerRe: addinmanager.h(89): error C4716: 'CAddinCommadInfo::operator=' is ??? Pin
thomas_tom9931-Jan-05 0:00
memberthomas_tom9931-Jan-05 0:00 
GeneralRe: addinmanager.h(89): error C4716: 'CAddinCommadInfo::operator=' is ??? Pin
thomas_tom9931-Jan-05 0:08
memberthomas_tom9931-Jan-05 0:08 
Questionwhat is the role of CFrameWorkAddin1 Pin
bensabat24-Dec-04 23:11
memberbensabat24-Dec-04 23:11 
AnswerRe: what is the role of CFrameWorkAddin1 Pin
thomas_tom9927-Dec-04 20:16
memberthomas_tom9927-Dec-04 20:16 
GeneralRe: what is the role of CFrameWorkAddin1 Pin
bensabat27-Dec-04 22:02
memberbensabat27-Dec-04 22:02 
Generalfails under vc7 - more precise Pin
bensabat17-Dec-04 22:06
memberbensabat17-Dec-04 22:06 
GeneralRe: fails under vc7 - more precise Pin
thomas_tom9919-Dec-04 16:57
memberthomas_tom9919-Dec-04 16:57 
GeneralRe: fails under vc7 - more precise Pin
thomas_tom9920-Dec-04 23:57
memberthomas_tom9920-Dec-04 23:57 
GeneralRe: fails under vc7 - more precise Answer Pin
thomas_tom9920-Dec-04 23:57
memberthomas_tom9920-Dec-04 23:57 
GeneralRe: fails under vc7 - more precise Answer Pin
bensabat21-Dec-04 4:31
memberbensabat21-Dec-04 4:31 
Generalfails under VC7 Pin
bensabat17-Dec-04 20:27
memberbensabat17-Dec-04 20:27 
GeneralDownload files Pin
Smitha Nishant5-Dec-04 23:59
protectorSmitha Nishant5-Dec-04 23:59 
GeneralRe: Download files Pin
Anonymous8-Dec-04 16:53
memberAnonymous8-Dec-04 16:53 
QuestionWhat about connections points ? Pin
bensabat5-Dec-04 3:32
memberbensabat5-Dec-04 3:32 
AnswerRe: What about connections points ? Pin
thomas_tom995-Dec-04 22:44
memberthomas_tom995-Dec-04 22:44 
GeneralRe: What about connections points ? Pin
thomas_tom999-Dec-04 20:08
memberthomas_tom999-Dec-04 20:08 
GeneralGudie Gudie Pin
ThatsAlok9-Dec-04 20:09
memberThatsAlok9-Dec-04 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190518.1 | Last Updated 10 Dec 2004
Article Copyright 2004 by thomas_tom99
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid