BCB5 - ActiveX (Variant vs TVariant) using ComponentWorks (Re-issued)

Hi again,

I try to re-issue my last post, regarding BCB5's handling of ActiveX and
Variant
types. My initial post, together with the reply is included hereafter.

Has anyone successfully implemented a ComponentWorks graph control,
using BCB5 and
has managed to pass Variant array type to it?

Thank you in advance,

Bent Christensen (b...@unigate.com)
Unigate Technologies
Lyshoejen 6
DK-8520 Lystrup
Denmark

Tel: +45 8743-3401
Fax: +45 8743-3419

======================================================================
Subject:         BCB5 - ActiveX (Variant vs TVariant) using
ComponentWorks
Date:            Mon, 06 Mar 2000 11:48:55 +0100
From:            Bent Christensen <b...@unigate.com>
Organization:    Another Netscape Collabra Server User
Newsgroups:      borland.public.cppbuilder.activex

Hi,

I am using National Instruments "ComponentWorks" which is an ActiveX
library, containing visual graph controls such as Graphs, LED's etc.

The graph component has a method called PlotY which according to the
documentation (and the type library) has the following definition:

   PlotY( Variant yData,
          Variant xFirst = 0,
          Variant xInc = 1,
          bPlotPerRow = true );

In the *ControlLib_OCX.h file, generated by the ActiveX import utility
the parameters has changed from type Variant to TVariant, as follows:

   PlotY( TVariant yData,
          TVariant xFirst/*[opt]*/= TNoParam(),
          TVariant xInc/*[opt]*/= TNoParam(),
          TVariant bPlotPerRow/*[opt]*/= TNoParam());

My initial fix to this, was to create a TVariant, to which I assigned
my Variant. This TVariant is then passed to the PlotY function:

  TVariant varDispT(varDispArray);             // Convert from Variant
(varDispArray) to TVariant

  plotControl->PlotY( varDispT, 0, 1, true );  // Plot data

Running the program with the BCB IDE works fine, but when I execute the
program
from the desktop of NT (Windows 2000), it crashes with an error message
telling me
that an invalid Variant operation has taken place.
Furhtermore, when the program is executed from within the IDE, the
BCB.EXE program,
according to Task Manager, has a memory leak, thus adding up used
memory.

Can anyone help me on this subject?

Thank you in advance,

Bent Christensen
Unigate Technologies

b...@unigate.com
======================================================================

Subject:Re:     BCB5 - ActiveX (Variant vs TVariant) using
ComponentWorks
Date:           Mon, 06 Mar 2000 13:02:35 -0800
From:           "Alex Bakaev [TeamB]" <al...@jetsuite.com>
Organization:   Another Netscape Collabra Server User
Newsgroups:     borland.public.cppbuilder.activex
References:     1

Bent, please don't use HTML when posting to this news server. Many
newsreaders can't handle it.

The TVariant is a wrapper around VARIANT, so you can call the method
passing regular values to it. The compiler will take care of wrapping
them ( rather, converting them ) to the appropriate type.

HTH,
Alex

Quote
Bent Christensen wrote:

[snip]

======================================================================

Subject:      Re: BCB5 - ActiveX (Variant vs TVariant) using
ComponentWorks
Date:         Wed, 08 Mar 2000 13:08:19 +0100
From:         Bent Christensen <b...@unigate.com>
Organization: Unigate Technologies
Newsgroups:   borland.public.cppbuilder.activex
References:   1 , 2

Thanks for the reply. Sorry about the format.

Your suggestion works fine as long as I use single regular values.
However, I need to pass an array to the function PlotY which should
be of type Variant.
If I pass a Variant array to the function I get a compiler error. The
only workaround I found is listed below. As mentioned earlier, this
works fine as long as the program is executed within the BCB5 IDE,
but when executed from the shell, the program fail/crashes with the
statement "Invalid Variant Operation".

  Variant varDispArray = VarArrayCreate( OPENARRAY( int, ( 0, iSize) ),
varDouble );

  double* padDisp = (double*) varDispArray.ArrayLock();

  for( int i=0; i<iSize; i++ ) {
    padDisp[i] = (double)pawArray[i];
  }
  varDispArray.ArrayUnlock();

  TVariant varDispT(varDispArray);

  plotControl->PlotY( varDispT, 0, 1, true );

Best regards,

Bent Christensen
======================================================================