Click here to Skip to main content
12,998,759 members (70,885 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 30 Jul 2000

ATL Collection Wizard

, 27 Aug 2000
Rate this:
Please Sign up or sign in to vote.
ATL object wizard that creates a collection of other COM objects
<!-- Download Links -->
  • Download source files - 18 Kb
  • Download wizard files - 18 Kb
  • Sample Image


    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.


    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.


    • 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.


    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


    About the Author

    David Peterson
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    GeneralOk Pin
    Vitaly Tomilov3-May-10 7:24
    memberVitaly Tomilov3-May-10 7:24 
    GeneralFantastic Wizard... Just a couple of updates to the distribution file collection.h (changes in bold) For use at your own risk! ;-) Pin
    Parko13-Apr-08 23:32
    memberParko13-Apr-08 23:32 
    QuestionHow to add outlook COM add-in Pin
    ramakrishnakadamati13-Jun-07 18:09
    memberramakrishnakadamati13-Jun-07 18:09 
    QuestionSorting? Pin
    Gary Chapman16-Feb-07 23:17
    memberGary Chapman16-Feb-07 23:17 
    AnswerRe: Sorting? Pin
    Dirty Highlander14-May-07 5:38
    memberDirty Highlander14-May-07 5:38 
    GeneralExcelent Pin
    Vider6-Sep-06 23:32
    memberVider6-Sep-06 23:32 
    GeneralRe: Excelent Pin
    Portatofe2-Oct-08 5:19
    memberPortatofe2-Oct-08 5:19 
    QuestionHow to use the wizard with visual studio 7? Pin
    AverageJoe11-May-06 22:43
    memberAverageJoe11-May-06 22:43 
    GeneralOLE Excel Pin
    Pham van hoi13-Aug-05 1:12
    memberPham van hoi13-Aug-05 1:12 
    GeneralMFC Pin
    sanpee4-May-05 0:50
    membersanpee4-May-05 0:50 
    Generalneed help Pin
    Anonymous27-Sep-04 22:46
    sussAnonymous27-Sep-04 22:46 
    GeneralFantastic, Just what I needed! Pin
    Parko19-Aug-04 0:55
    memberParko19-Aug-04 0:55 
    GeneralIntellisense Pin
    qur24-Feb-04 19:25
    memberqur24-Feb-04 19:25 
    GeneralGreat Job - One small problem Pin
    Mick O'Neill23-Mar-03 18:41
    memberMick O'Neill23-Mar-03 18:41 
    GeneralGood Job!!! Pin
    BleuBleu30-Jan-02 7:10
    memberBleuBleu30-Jan-02 7:10 
    Generalhmmm Pin
    savaisan16-Dec-01 4:47
    membersavaisan16-Dec-01 4:47 
    GeneralAnother small bug .. in COLLECTION.H Pin
    David Patrick30-Oct-01 10:23
    memberDavid Patrick30-Oct-01 10:23 
    GeneralSmall but serious bug Pin
    Pavlos Touboulidis22-Aug-01 0:37
    memberPavlos Touboulidis22-Aug-01 0:37 
    QuestionDon'n you think that, may be better to add "restricted" keyword in idl definition of _NewEnum? Pin
    Sergey Anisimov1-Jun-01 4:21
    memberSergey Anisimov1-Jun-01 4:21 
    QuestionHow do I get COM objects into this collection ? Pin
    NicA16-May-01 6:14
    memberNicA16-May-01 6:14 
    AnswerRe: How do I get COM objects into this collection ? Pin
    Tom Mason24-May-01 23:39
    memberTom Mason24-May-01 23:39 
    GeneralRe: How do I get COM objects into this collection ? Pin
    NicA28-May-01 23:49
    memberNicA28-May-01 23:49 
    GeneralRe: How do I get COM objects into this collection ? Pin
    Tom Mason29-May-01 0:33
    memberTom Mason29-May-01 0:33 
    AnswerRe: How do I get COM objects into this collection ? Pin
    Ivan1410-Aug-01 2:20
    memberIvan1410-Aug-01 2:20 
    GeneralWizard support for stl::map container Pin
    Gerald Hackenberg15-May-01 3:01
    memberGerald Hackenberg15-May-01 3:01 

    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.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.170622.1 | Last Updated 28 Aug 2000
    Article Copyright 2000 by David Peterson
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid