Click here to Skip to main content
Licence 
First Posted 30 Jul 2000
Views 154,197
Bookmarked 46 times

ATL Collection Wizard

By | 27 Aug 2000 | Article
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

    About the Author

    David Peterson



    United States United States

    Member



    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    GeneralOk PinmemberVitaly Tomilov7:24 3 May '10  
    GeneralFantastic Wizard... Just a couple of updates to the distribution file collection.h (changes in bold) For use at your own risk! ;-) PinmemberParko23:32 13 Apr '08  
    QuestionHow to add outlook COM add-in Pinmemberramakrishnakadamati18:09 13 Jun '07  
    QuestionSorting? PinmemberGary Chapman23:17 16 Feb '07  
    AnswerRe: Sorting? PinmemberDirty Highlander5:38 14 May '07  
    GeneralExcelent PinmemberVider23:32 6 Sep '06  
    GeneralRe: Excelent PinmemberPortatofe5:19 2 Oct '08  
    QuestionHow to use the wizard with visual studio 7? PinmemberAverageJoe22:43 11 May '06  
    GeneralOLE Excel PinmemberPham van hoi1:12 13 Aug '05  
    GeneralMFC Pinmembersanpee0:50 4 May '05  
    Generalneed help PinsussAnonymous22:46 27 Sep '04  
    GeneralFantastic, Just what I needed! PinmemberParko0:55 19 Aug '04  
    GeneralIntellisense Pinmemberqur19:25 24 Feb '04  
    GeneralGreat Job - One small problem PinmemberMick O'Neill18:41 23 Mar '03  
    GeneralGood Job!!! PinmemberBleuBleu7:10 30 Jan '02  
    Generalhmmm Pinmembersavaisan4:47 16 Dec '01  
    GeneralAnother small bug .. in COLLECTION.H PinmemberDavid Patrick10:23 30 Oct '01  
    GeneralSmall but serious bug PinmemberPavlos Touboulidis0:37 22 Aug '01  
    QuestionDon'n you think that, may be better to add "restricted" keyword in idl definition of _NewEnum? PinmemberSergey Anisimov4:21 1 Jun '01  
    QuestionHow do I get COM objects into this collection ? PinmemberNicA6:14 16 May '01  
    AnswerRe: How do I get COM objects into this collection ? PinmemberTom Mason23:39 24 May '01  
    GeneralRe: How do I get COM objects into this collection ? PinmemberNicA23:49 28 May '01  
    GeneralRe: How do I get COM objects into this collection ? PinmemberTom Mason0:33 29 May '01  
    AnswerRe: How do I get COM objects into this collection ? PinmemberIvan142:20 10 Aug '01  
    GeneralWizard support for stl::map container PinmemberGerald Hackenberg3:01 15 May '01  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
    Web01 | 2.5.120517.1 | Last Updated 28 Aug 2000
    Article Copyright 2000 by David Peterson
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid