October 27, 2016
Hot Topics:

Converting a Win32 Application to ATL

  • May 9, 2000
  • By Chandra Shekar
  • Send Email »
  • More Articles »

Migration Steps

  1. Include AtlBase.h file in StdAfx.h after AfxWin.h. This is to take advantage to declare a variable for CComModule. Because AtlWin.h file needs, _Module as variable of CComModule.
    #include <atlbase.h>
    #include <objbase.h>
    We have to keep extern because we are originally declaring variable in Application main file.
    extern CComModule _Module;
    Then include the remaining files which helps for an ATL Application. In the insert Object of ATL uses ATLHost.h which needs to compile atlcom.h as before.
    #include <atlwin.h>
    #include <atlcom.h>
  2. In the StdAfx.cpp, Include AtlImpl.cpp file.
  3. In the main Application file, add the following
    <font color=green>//originally declaring the CComModule variable</font>
    CComModule _Module; 
    Then, Add the following two lines, which are required to activate ATL Object Wizard, when you choose Insert ATLObject from Insert Menu.
  4. Initialize the CComModule variable with ObjectMap and with the current instance in the WinMain function
    _Module.Init(ObjectMap, hInstance);
  5. Add the <ProjectName>.idl file into the project and add the library related code:
    library TestLIB
  6. If you want to insert a dialog and want to show. Follow the above steps and declare the variable of ur dialog class and call DoModal with that variable (don't forget to include dlg header file).

Additional Notes

This code has been tested with and works fine with the Windows CE environment.

References and Acknowledgments

  • ATL Internals - Rector, Sells (My thanks to the Authors!)

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel