const VARIANT& 
Author Message
 const VARIANT&

Hello there.

At the moment I am trying to incorporate a number of OCXs in a project
of mine. I am working in DBSee++. (c++ database development)

One of my main problems is that OCXs are not fully supported.
Therefore I have to create wrapper classes (using VC++ 5.0).

However a lot of the methods of the wrapper classes take paramaters of
type, const VARIANT&.
I can tell from the OCX help files what datatype the method requires.

So how do I declare the const VARIANT&?
How do I initialise the actual data item that I want to pass.

e.g.

void MyOCX::DoIt(const VARIANT& param);

Help file tells me that DoIt() takes a logical value.

I've tried.

const VARIANT& myval;
myval.bool = 1;

Object.DoIt(myval);

I get an error saying "references must be initialised"

& "bool is not a member of tagVARIANT"

So basically I don't understand the tagVARIANT structure and I don't
know how to initialise a reference.

Any suggestions appreciated.

b.t.w. I'm pretty green when it comes to VC++.



Tue, 20 Feb 2001 03:00:00 GMT  
 const VARIANT&

Quote:

>Hello there.

>At the moment I am trying to incorporate a number of OCXs in a project
>of mine. I am working in DBSee++. (c++ database development)

>One of my main problems is that OCXs are not fully supported.
>Therefore I have to create wrapper classes (using VC++ 5.0).

>However a lot of the methods of the wrapper classes take paramaters of
>type, const VARIANT&.
>I can tell from the OCX help files what datatype the method requires.

>So how do I declare the const VARIANT&?

You don't need to declare a variable of this type.  Create a variable
of type VARIANT, initialize it, and directly pass it to your DoIt()
method.

Your VARIANT variable will be automatically cast to the "const" type
(The reverse cannot be done without explicitly casting away the "const").

Quote:
>How do I initialise the actual data item that I want to pass.

>e.g.

>void MyOCX::DoIt(const VARIANT& param);

>Help file tells me that DoIt() takes a logical value.

>I've tried.

>const VARIANT& myval;

VARIANT myval;  // The rest of your code is fine.

Quote:
>myval.bool = 1;

>Object.DoIt(myval);

>I get an error saying "references must be initialised"

>& "bool is not a member of tagVARIANT"

>So basically I don't understand the tagVARIANT structure and I don't
>know how to initialise a reference.

--------------------------------------------------------------------------------

Principal Software Engineer       Corporate Web Page:     http://www.xiotech.com

Eden Prairie, MN                  Personal Home Page:   http://www.visi.com/~nde

"Question authority...and the authorities will end up questioning YOU!"
--------------------------------------------------------------------------------



Sun, 25 Feb 2001 03:00:00 GMT  
 const VARIANT&
Thanks for the reply Andy.

Now my only problem is, I don't know how to initialise the BOOL value
of a tagVARIANT structure.

VARIANT_BOOL bool;  is a member of an anonymous union in struct
tagVARIANT.

I've tried..

VARINAT MyVariant;
MyVariant.bool = 1;

I get an error saying "bool" is not a member of structure tagVARIANT.

Any Suggestions?

Thanks

Joe


Quote:

>>So how do I declare the const VARIANT&?

>You don't need to declare a variable of this type.  Create a variable
>of type VARIANT, initialize it, and directly pass it to your DoIt()
>method.

>Your VARIANT variable will be automatically cast to the "const" type
>(The reverse cannot be done without explicitly casting away the "const").



Mon, 26 Feb 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Howto: CString into const VARIANT&

2. How to pass (const VARIANT& helpArg)long

3. How to pass (const VARIANT& helpArg)long

4. How to pass const Variant& ??

5. What's const VARIANT& ?

6. How to pass const Variant& ??

7. Help: inline char const* const& max(char const* const &a, char const* const &b)

8. ActiveX - Passing variant array from VBScript & C#

9. VARIANT & VT_PTR

10. Variant & Automation

11. VARIANT & VTS_VARIANT

12. Converting a value to VARIANT&

 

 
Powered by phpBB® Forum Software