| C & C++ Programming | MFC Programming | Download | Site Index |


 

 

 

 

Supplementary note for MFC Programming Module 24

 

 

 

 

 

What do we have in this Module?

  1. COleVariant Class

  2. COleVariant Members

  3. Construction

  4. Operations

  5. Operators

  6. Archive/Dump

 

 

COleVariant Class

 

class COleVariant : public tagVARIANT

 

A COleVariant object encapsulates the VARIANT data type. This data type is used in OLE automation. Specifically, the DISPPARAMS structure contains a pointer to an array of VARIANT structures. A DISPPARAMS structure is used to pass parameters to IDispatch::Invoke.

This class is derived from the VARIANT structure. This means you can pass a COleVariant in a parameter that calls for a VARIANT and that the data members of the VARIANT structure are accessible data members of COleVariant. The two related MFC classes COleCurrency and COleDateTime encapsulate the variant data types CURRENCY (VT_CY) and DATE (VT_DATE). The COleVariant class is used extensively in the DAO classes; see these classes for typical usage of this class, for example CDaoQueryDef and CDaoRecordset. The afxdisp.h must be included in order to use this class.

 

COleVariant Members

 

Construction

 

COleVariant

Constructs a COleVariant object.

 

Table 1.

 

Operations

 

Attach()

Attaches a VARIANT to a COleVariant.

ChangeType()

Changes the variant type of this COleVariant object.

Clear()

Clears this COleVariant object.

Detach()

Detaches a VARIANT from a COleVariant and returns the VARIANT.

GetByteArrayFromVariantArray()

Retrieves a byte array from an existing variant array.

SetString()

Sets the string to a particular type, typically ANSI.

 

Table 2.

 

Operators

 

operator =

Copies a COleVariant value.

operator ==

Compares two COleVariant values.

operator LPCVARIANT

Converts a COleVariant value into an LPCVARIANT.

operator LPVARIANT

Converts a COleVariant object into an LPVARIANT.

 

Table 3.

 

Archive/Dump

 

operator <<

Outputs a COleVariant value to CArchive or CDumpContext.

operator >>

Inputs a COleVariant object from CArchive.

 

Table 4.

 

 

 

 

 

 


| C & C++ Programming | MFC Programming | Download | Site Index |