Passing pointers to C++ ActiveX controls in VB 
Author Message
 Passing pointers to C++ ActiveX controls in VB

I'm using an C++ activeX control in a VB form.
In this control, there's a method :

getinfo(float *info) {}

How can I use this method in VB ?
I tried:
Dim i as single
getinfo(i)

But at runtime it says : "wrong argument type"

The problem is coming from the float* I guess.
Is there a solution ?

Thanks
Ludovic Launer



Mon, 02 Jul 2001 03:00:00 GMT  
 Passing pointers to C++ ActiveX controls in VB
You might try to look at the control with the OLE/COM Object viewer,  it is
a good chance that the method is defined somewhat like this

HRESULT GetInfo(float *info)

with a type lib def like this

HRESULT GetInfo([out,retval] float *info)

if that is the case, you would access the method like this

Dim i as single
i=getinfo()

since a return value to VB is the final argument to VC.

Vincent Minden


Quote:
>I'm using an C++ activeX control in a VB form.
>In this control, there's a method :

>getinfo(float *info) {}

>How can I use this method in VB ?
>I tried:
>Dim i as single
>getinfo(i)

>But at runtime it says : "wrong argument type"

>The problem is coming from the float* I guess.
>Is there a solution ?

>Thanks
>Ludovic Launer




Mon, 02 Jul 2001 03:00:00 GMT  
 Passing pointers to C++ ActiveX controls in VB
The method is not defined as you mentioned.
In the COM/OLE object viewer, both for the ocx and the type lib it is
defined as ;
void getinfo(single* info);

I added a method using the class wizard. Could that be the problem ?
In that case how should I declare in VC a method for my activeX which would
be able to change the values of its given parameters ?

Same kind of question : Can a VC method in an activeX control return an
"array" which could be used in VB ? how ?

Thanks.

Ludovic Launer



Mon, 02 Jul 2001 03:00:00 GMT  
 Passing pointers to C++ ActiveX controls in VB
You didn't tell the wizard what the parameter was.  You'll need to modify
the IDL by hand to say:

void getinfo([in, out] single* info);

I believe.  Then recompile the COM object and try it again in VB.

As for Arrays, yes, however, it's not as easy as you'd hope.  (i.e. the code
above is not the right first step.)  If it's pure VB (not VBScript), I
believe you can get away with:

void getmoreinfo([out, in] long * psizeInOut, [out, size_is(*psizeInOut)]
single arrayOut[]);

However, I'm not 100% sure that will work, and it's definitely not
recommended.

The "right" way to do it is with a SAFEARRAY, but that's a complicated topic
in and of itself:

void getsafeinfo([out,retval] VARIANT* info);

where the Variant contains the SAFEARRAY.  FWIW, I highly recommend picking
up a book on this topic.  Which book depends on whether you're using ATL or
MFC or coding this stuff manually.

One final topic, you might try the following newsgroups for COM stuff.
You'll get a little better response to these types of questions:

microsoft.public.vc.mfcole  (If you're using MFC to write your ActiveX
stuff)
microsoft.public.vc.activex.templatelib (If you're using ATL to write your
ActiveX stuff)
microsoft.public.win32.programmer.ole (Generic COM group)

HTH

--
Reginald Blue                   | Opinions expressed here do not
Natural Language Understanding  | necessarily represent those of
Unisys Corporation              | my employer.
                                |-------------------------------
                                | My email address is wrong, you

Quote:

>The method is not defined as you mentioned.
>In the COM/OLE object viewer, both for the ocx and the type lib it is
>defined as ;
>void getinfo(single* info);

>I added a method using the class wizard. Could that be the problem ?
>In that case how should I declare in VC a method for my activeX which would
>be able to change the values of its given parameters ?

>Same kind of question : Can a VC method in an activeX control return an
>"array" which could be used in VB ? how ?

>Thanks.

>Ludovic Launer




Mon, 02 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to pass pointer to ActiveX Control from VB

2. accessing objects in a c++ DLL from a c++ activeX control placed in a VB application

3. accessing objects in a c++ DLL from a c++ activeX control placed in a VB application

4. passing activeX from vb to c++

5. Passing a Binary Buffer between an ActiveX control and VB client

6. ? regarding passing data from VC to VB using ActiveX control

7. How String Array passed to VB ActiveX Control

8. pass vb.net function pointer to Managed C++

9. Question: Catching errors from a VB ActiveX control in Visual C++ using MFC

10. Adding a COM i/f to a VB ActiveX control from a C++ tlb

11. ActiveX C++ using ActiveX VB

12. Problem using VB 5 activex DLL in a VC++ activex control

 

 
Powered by phpBB® Forum Software