Re: Can I have a static Class / COM object in my ATL control?
I can only concur with Brian here...
However, if this COM object is a frontend for something
persistent (like an application), this may be defined as a
preference and persisted via non-COM means (for example
in the registry) by that application.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Brian Muth" <bmuth@mvps.org> wrote in message
news:O9%23jPGhNHHA.3288@TK2MSFTNGP03.phx.gbl...
"nospam" <nospam@nospam.com> wrote in message
news:FXCph.3351$3h5.1412@trnddc01...
Alexander Nickolov wrote:
Use a global class instance of a regular C++ class.
Not sure why would you want a "static" COM object
(nor what you mean by that). Perhaps a singleton COM
object is what you are looking for? Note these can only
be hosted by executables, so not an option for a control
(controls are hosted in DLLs).
Thanks Alexander.
This is for a DLL.
Here is what I want to do.
I have a com object called Waypoint.
This COM object has a property called Identifier. Identifier is a BSTR.
Normally BSTR will be converted to uppercase on set_Identifier. I want
to give my end user programmer the option of set_Identifier to not
perform this conversion. I really don't want the end user programmer to
have to set a "DontConvert" property each time they use a different
instance of the Waypoint object or do I want to have them supply it as a
parameter for the property (is is common practice anyway?). So what I
really need is a global variable. Any ideas on how I can do this?
The behaviour of a COM object (such as how a property is handled) should
be defined as a property or a method of an interface. I don't see what the
advantage of a global variable is other than to break this convention.
Perhaps you can provide us with an argument.
Brian