Snap-In Interface Technology + Embedded MFC GUI into ATL Server DLL
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:
- Create a regular MFC exe application framework with App wizard.
- Include in your project files: ISnapin.h, ISnapinCallbacks.h, SnapFrm.cpp, SnapFrm.h, SnapIn.cpp, SnapIn.h.
- Derive CMainFrame class from CSnapInFrame instead of CFrameWnd (or CMDIFrameWnd). Easiest way would to add thisl line right above CMainFrame delaration: #define CFrameWnd CSnapInFrame
- Your application is now fully Snap-In ready!
Snap In:
- Create a ATL COM Project with ATL App Wizard. Add it to a current workspace Select it to be a DLL with MFC support.
- Add ATL class to this project (for instance CSnapinOne).
- Replace base ISnapinOne to ISnapIn, so the class is derived from ISnapIn interface instead.
Downloads
Download compiled demo - 11 KbDownload source code for demo project - 63 Kb

Comments
Need to implement ISnapIn as ATL class
Posted by Legacy on 03/05/2003 12:00amOriginally posted by: joe
Reply
error C2787
Posted by Legacy on 02/14/2003 12:00amOriginally posted by: Andreas Frey
ReplyKeyboard handling
Posted by Legacy on 01/17/2003 12:00amOriginally 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.
Reply
How about a toolbar?...
Posted by Legacy on 06/07/2002 12:00amOriginally 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.
ReplyThere 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?...
:o)