home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / mfcatl / mfcatl.txt < prev    next >
Text File  |  1998-03-26  |  2KB  |  42 lines

  1.  
  2. MFCATL
  3.  
  4. This sample illustrates how ATL COM objects can be used in an MFC server EXE.
  5. The server allows the creation of two objects, "ObjectOne" (implemented in MFC and
  6. supporting a dispinterface) and "ObjectTwo" (implemented in ATL and supporting a
  7. dual interface).
  8.  
  9. HOW TO RUN IT:
  10. Build the MfcAtl.EXE server and run it standalone to register it.
  11. Load the MfcAtl.VBP Visual Basic 4.0 project, run it, and press the buttons in the form.
  12. Note that if you are running the sample on NT 3.51 then only the release build will work.
  13.  
  14. REMARKS:
  15. Originally, the project had both objects implemented in MFC (by deriving them from CCmdTarget).
  16. "ObjectTwo" has been reimplemented using ATL. In doing so, these steps were followed:
  17.  
  18. * Included ATL header files (atlbase.h and atlcom.h) into premfcat.h
  19. * Included atlimpl.cpp into premfcat.cpp
  20. * Added a CComModule derived class to premfcat.h (similar to the beeper .EXE sample)
  21.     and implemented the Lock() an Unlock() methods to forward lock counts to MFC by calling
  22.     AfxOleLockApp()/AfxOleUnlockApp()
  23. * Added an object map macro pair (BEGIN_OBJECT_MAP()/END_OBJECT_MAP()) into the MfcAtl.cpp
  24.     and added a static instance of the module class called _Module
  25. * Called _Module.Init() and Term() from InitInstance() and ExitInstance()
  26. * Added the typelib as a resource
  27. * Called _Module.RegisterServer(TRUE) from InitInstance(), to match the MFC call to
  28.     COleObjectFactory::UpdateRegistryAll()
  29. * Called _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE), matching
  30.     the REGCLS_MULTIPLEUSE of MFC's class factories, as implicitly done by the
  31.     IMPLEMENT_OLECREATE() macro
  32. * Reimplemented "ObjectTwo" using ATL:
  33.     + changed the ODL file from dispinterface to dual interface
  34.     + had the ODL compilation generate a header file (interf.h), needed by ATL
  35.     + rewrote .h and .cpp file (the quickest way is to run ATL Wizard and copy/paste/rename
  36.       the automatically generated code in place of the original MFC one)
  37.     + added an OBJECT_ENTRY(CLSID_ObjectTwo, CObjectTwo) to the ATL object map
  38.  
  39. Additional conversion steps (not covered here) might include:
  40. * porting the ODL file to IDL format
  41. * adding support for -RegServer and -UnregServer command line arguments
  42.