Parameterized constructor in MFC/COM??
-
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
-
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
-
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
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 asenum
, see theIDL
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.
-
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
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