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

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 24, 2000
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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.

App:

  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.

Downloads

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.