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. COM
  4. Parameterized constructor in MFC/COM??

Parameterized constructor in MFC/COM??

Scheduled Pinned Locked Moved COM
c++javacomtestingtools
4 Posts 4 Posters 0 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.
  • V Offline
    V Offline
    vb116
    wrote on last edited by
    #1

    I am creating "MFC AppWizard(Dll) with Automation" in VC++ 6.0, We are in the process of developing COM wrapper equivalent to java library for windows developers. I am not able to find following equivalents of java in COM - Defining Constant fields(as only interface is exposed, can we declare const fields in interface??) - Defining and calling parameterizing constructor Can anybody shade some light on this? Thanks, Bhavesh

    P C R 3 Replies Last reply
    0
    • V vb116

      I am creating "MFC AppWizard(Dll) with Automation" in VC++ 6.0, We are in the process of developing COM wrapper equivalent to java library for windows developers. I am not able to find following equivalents of java in COM - Defining Constant fields(as only interface is exposed, can we declare const fields in interface??) - Defining and calling parameterizing constructor Can anybody shade some light on this? Thanks, Bhavesh

      P Offline
      P Offline
      Phil Harding
      wrote on last edited by
      #2

      COM objects cannot have parameterised constructors COM interfaces can only contain method definitions, but you could declare a constant in a COM type library


      - "I'm not lying, I'm just writing fiction with my mouth"

      Phil Harding.
      myBlog [^] | mySite [^]

      1 Reply Last reply
      0
      • V vb116

        I am creating "MFC AppWizard(Dll) with Automation" in VC++ 6.0, We are in the process of developing COM wrapper equivalent to java library for windows developers. I am not able to find following equivalents of java in COM - Defining Constant fields(as only interface is exposed, can we declare const fields in interface??) - Defining and calling parameterizing constructor Can anybody shade some light on this? Thanks, Bhavesh

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        Bhavesh Vaghela wrote:

        - Defining Constant fields(as only interface is exposed, can we declare const fields in interface??)

        Since COM objects exposes interfaces only, you can only create a method returning a constant value. BTW you can define constats as enum, see the IDL reference.

        Bhavesh Vaghela wrote:

        Defining and calling parameterizing constructor

        You cannot do this, since you don't explicitely create a COM object, there's an associated ClassObject that do it for you. Hope that helps. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        1 Reply Last reply
        0
        • V vb116

          I am creating "MFC AppWizard(Dll) with Automation" in VC++ 6.0, We are in the process of developing COM wrapper equivalent to java library for windows developers. I am not able to find following equivalents of java in COM - Defining Constant fields(as only interface is exposed, can we declare const fields in interface??) - Defining and calling parameterizing constructor Can anybody shade some light on this? Thanks, Bhavesh

          R Offline
          R Offline
          Roger Stoltz
          wrote on last edited by
          #4

          Bhavesh Vaghela wrote:

          I am not able to find following equivalents of java in COM

          :confused::confused: Java is a programming language, but COM is a technique that can be implemented in several languages e.g. C/C++, VB, Java etc. It doesn't make sense to compare those two.

          Bhavesh Vaghela wrote:

          Defining Constant fields

          I don't get what you mean by that, but perhaps a look at some IDL documentation[^] would help.

          Bhavesh Vaghela wrote:

          Defining and calling parameterizing constructor

          In COM you don't have a "constructor", you have a class factory that creates the instance which is created and called when the client calls ::CoCreateInstance(...). Technically you can have different constructors and edit the class factory to make use of them, but there's really no point. You should use persistent storage and monikers instead to let the server know how it should initialize itself.


          "It's supposed to be hard, otherwise anybody could do it!" - selfquote
          "High speed never compensates for wrong direction!" - unknown

          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