Snap-In Interface Technology + Embedded MFC GUI into ATL Server DLL

Web site

This code in large borrowed from an article and code sample by Steve Zimmerman "Create Apps That Are Easily Extensible with Our Smart "Snap-Ins" Methodology".   Its been updated to work with ATL 3.0 and VC 6.0, plus a few extra modifications and demonstartions of the coolest technologies :).

To see this sample code in action run the ComSnapin.exe. Your screen will look like this:

It has only 4 menu items: File; Edit; View; and Help.

Now run register.bat located in SnapinOne\ReleaseMinSize directory. This batch file will register SnapinOne.dll with the system. Run ComSnapin.exe again. Your screen should look like this:

There ia a new menu item: Snapin Commands. If you click on the menu item a Doc-View window will popup. This Doc/view framework is entirely confined inside SnapinOne.dll which is a ATL dll server.

If you run unregister.bat which will unregister SnapinOne.dll and excute program again you'll see that the menu item gone.

SnapinOne.dll can communicate with parent application via callback interfaces and obtain from it whatever information it tries to digest.

This gives your "Snapin" enabled parent program virtualy unlimited scalability.


  1. Create a regular MFC exe application framework with App wizard.
  2. Include in your project files: ISnapin.h, ISnapinCallbacks.h, SnapFrm.cpp, SnapFrm.h,   SnapIn.cpp, SnapIn.h.
  3. Derive CMainFrame class from CSnapInFrame instead of CFrameWnd (or CMDIFrameWnd). Easiest way would to add thisl line right above CMainFrame delaration:  #define CFrameWnd CSnapInFrame
  4. Your application is now fully Snap-In ready!

Snap In:

  1. Create a ATL COM Project with ATL App Wizard.  Add it to a current workspace Select it to be a DLL with MFC support.
  2. Add ATL class to this project (for instance CSnapinOne).
  3. Replace base ISnapinOne to ISnapIn, so the class is derived from ISnapIn interface instead.


Download compiled demo - 11 Kb
Download source code for demo project - 63 Kb


  • Need to implement ISnapIn as ATL class

    Posted by Legacy on 03/05/2003 12:00am

    Originally posted by: joe

    I would like to see you implement the ISnapIn and ISnapInCallback interfaces and basically the whole ComSnapIn project as regular ATL interfaces in stead of MFC ones. (just like the snapin is now ) 

    I'm trying to do so, but once i derive my ISnapInOne interface from the ATL equivalent of ISnapIn, lot's of errors occur which i can't explain yet. Could you help me out ? ---->

    class CSnapinOne :
    public ISnapIn,
    public CCallbackHelper,
    public CComObjectRoot,
    public CComCoClass<CSnapinOne,&CLSID_SnapinOne>
    CSnapinOne() {}
    END_COM_MAP() etc.etc.etc....

    this failes when the ISnapIn itself is an ATL based interface....

  • error C2787

    Posted by Legacy on 02/14/2003 12:00am

    Originally posted by: Andreas Frey

    Can anybody help me out ?!

    if i try to replace base ATL class with ISnapIn, i get error C2787 "no GUID has been associated with this object"
    The things work well in demo project, but if i try to make my own snapin server i cannot change:


    i have to leave it original:

    the files look quite like the ones in demo project, but dont work!
    Can anybody help me out?

  • Keyboard handling

    Posted by Legacy on 01/17/2003 12:00am

    Originally posted by: S

    How can you catch all keyboard events when snapin is active? Some keyboard messages seems to be processed in main window and not in snapin.

  • How about a toolbar?...

    Posted by Legacy on 06/07/2002 12:00am

    Originally posted by: Vitaly

    Try to add a toolbar to the Main Frame and you will see that things are not so simple and beatiful as it may seem.
    There is not a direct way to support buttons update and tooltips... Plus, status bar does not show the CAPS, NUM and INS updates as well.
    Do you have some ideas how to implement it?...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds