Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. New to ATL... (simple question)

New to ATL... (simple question)

Scheduled Pinned Locked Moved ATL / WTL / STL
c++questiontestingtools
3 Posts 2 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Deem
    wrote on last edited by
    #1

    Hi, I'm kinda new to ATL and as such I'm after a little guidance :) Say i want to be able to get Cheeseburger objects from Maccas. ie. A client would have to create a Maccas and then ask it for a Cheeseburger. I can create the Maccas class using the ATL create object wizard, but i am unsure how i should create the stub code for the Cheeseburger object. Do i use the object wizard again? Would this not unnecessarily create a CoClass for the object and make it seperately instantiable (you don't have to get Cheeseburgers from Maccas anymore). How else do i do it? In case it is important its desireable to support c++ and VB automation clients (scripted from office macros). Thanks a bunch! Alex

    P 1 Reply Last reply
    0
    • A Alex Deem

      Hi, I'm kinda new to ATL and as such I'm after a little guidance :) Say i want to be able to get Cheeseburger objects from Maccas. ie. A client would have to create a Maccas and then ask it for a Cheeseburger. I can create the Maccas class using the ATL create object wizard, but i am unsure how i should create the stub code for the Cheeseburger object. Do i use the object wizard again? Would this not unnecessarily create a CoClass for the object and make it seperately instantiable (you don't have to get Cheeseburgers from Maccas anymore). How else do i do it? In case it is important its desireable to support c++ and VB automation clients (scripted from office macros). Thanks a bunch! Alex

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      What I usually do is let ATL create it through the class wizard, then remove the stuff that I do not need. So as you said, you do not want to create it using the CoClass object. Therefore remove the derivation from CComCoClass in your Cheesburger class. You will also need to go to the main cpp file of your project where the DLL entry point is located and remove the Cheeseburger entry from the BEGIN_OBJECT_MAP map. This map tells the DLL which objects can be instantiated through CoCreateInstance. That is all that you will need to do in order to prevent the object from being instantiated outside of your DLL. Then when you want to instantiate your class from the Maccas object, you will not be able to use new Cheeseburger because your class is still an abstract base class. You will actually need to do something like this: CCheeseburger *pCheeseBurger = CComObject<CCheeseburger> Good Luck


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      A 1 Reply Last reply
      0
      • P Paul M Watt

        What I usually do is let ATL create it through the class wizard, then remove the stuff that I do not need. So as you said, you do not want to create it using the CoClass object. Therefore remove the derivation from CComCoClass in your Cheesburger class. You will also need to go to the main cpp file of your project where the DLL entry point is located and remove the Cheeseburger entry from the BEGIN_OBJECT_MAP map. This map tells the DLL which objects can be instantiated through CoCreateInstance. That is all that you will need to do in order to prevent the object from being instantiated outside of your DLL. Then when you want to instantiate your class from the Maccas object, you will not be able to use new Cheeseburger because your class is still an abstract base class. You will actually need to do something like this: CCheeseburger *pCheeseBurger = CComObject<CCheeseburger> Good Luck


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        A Offline
        A Offline
        Alex Deem
        wrote on last edited by
        #3

        Thank you, thank you, thank you! :-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups