Click here to Skip to main content
15,890,527 members
Articles / Desktop Programming / ATL
Article

ATL Collection Wizard

Rate me:
Please Sign up or sign in to vote.
4.73/5 (8 votes)
27 Aug 2000 195.5K   1.7K   47   37
ATL object wizard that creates a collection of other COM objects
  • Download source files - 18 Kb
  • Download wizard files - 18 Kb
  • Sample Image

    Introduction

    One evening, tired of creating COM collections by hand, I created an object wizard to handle the grunt work for me. This wizard will implement the popular ICollectionOnSTLImpl interface, providing a few enhancements for a collection. The code this wizard writes was inspired by the book "ATL Internals" (Addison-Wesley Pub Co; ISBN: 0201695898). I trust what the authors in that book wrote and haven't stopped to try to understand it all. But nonetheless...on with the wizard.

    Comments

    Sample Image

    You can choose which STL container your collection is based on, as well as the methods your collection will expose beyond the standard-issue methods provided by ICollectionOnSTLImpl. Typically, when I design collections I don't want the user to be able to create the collection themselves. Hence, the "non-creatable" and "unregistered" options. "Unregistered" will simply add the DECLARE_NO_REGISTRY to your collection's CoClass, but the "Non-creatable" option presented a real problem for me while writing this wizard. There is no method exposed by the ATL Object Wizard that allows me to add the proper OBJECT_ENTRY_NON_CREATEABLE macro to the object map. So, when this option is chosen, I throw a bogus value into the OBJECT_ENTRY macro to force a compile error. It is up to the developer to rectify the problem by inserting the proper macro. A cute message box will remind you of this when choosing this option.

    Deficiencies

    • I didn't have time to create an install package for everyone to use, so the installation is manual but straight-forward. Simply copy everything but the *.dll into your "<DevStudioDirectory>\Common\MSDev98\Template\ATL" directory, and then copy and register the *.dll anywhere you'd like. Next time you run the ATL Object Wizard, you'll be able to create a collection based on what I've written.
    • Beneath all of the typedefs and Impls is the collection's workhorse, IEnumVARIANT. Some developers might wish to use a different IEnumXXX, so they'll have to alter the code manually.
    • This wizard doesn't support the stl::map container. It will in the future.
    • You MUST compile the IDL file at least once before using this wizard. This is because the wizard uses the project's typelib to discover the COM objects that the collection can contain.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    United States United States
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralGreat Work Pin
    14-Apr-01 2:38
    suss14-Apr-01 2:38 
    GeneralRe: Great Work Pin
    Pham van hoi30-Aug-05 2:16
    Pham van hoi30-Aug-05 2:16 
    GeneralBeautiful Pin
    Nick Carruthers29-Mar-01 10:27
    Nick Carruthers29-Mar-01 10:27 
    Generalhelp me Pin
    linghuchong16-Dec-00 16:34
    linghuchong16-Dec-00 16:34 
    GeneralRe: help me Pin
    24-Jul-01 5:13
    suss24-Jul-01 5:13 
    GeneralDoesn't seem to work... Pin
    7-Dec-00 6:30
    suss7-Dec-00 6:30 
    GeneralRe: Doesn't seem to work... Pin
    19-Sep-01 8:47
    suss19-Sep-01 8:47 
    GeneralRe: Doesn't seem to work... Pin
    19-Sep-01 8:51
    suss19-Sep-01 8:51 
    GeneralCool! Pin
    James White15-Sep-00 8:29
    James White15-Sep-00 8:29 
    GeneralDoes NOT work :-( Pin
    Tom6-Aug-00 5:18
    Tom6-Aug-00 5:18 
    GeneralRe: Does NOT work :-( Pin
    Member 78532824-Dec-03 8:09
    Member 78532824-Dec-03 8:09 
    GeneralDLL source Pin
    John Bates31-Jul-00 14:59
    John Bates31-Jul-00 14:59 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.