Board index » cppbuilder » BCB4 still cannot use VB5/VB6 ActiveX Controls?

BCB4 still cannot use VB5/VB6 ActiveX Controls?

Can anyone confirm or deny whether BCB4 can use OCX's created with VB5 or VB6?
I just got my copy of BCB4, and tried creating a simple ActiveX Control in
VB6.  The ActiveX has one property and one method.

The control imports fine into the BCB4 IDE, but when I use the control in a
project, the property works fine (I can "get" and "set" it), but the method
fails (no exceptions, no error messages - it just doesn't work).

MyActiveXControl->MyProp = 5;   // works great!
MyActiveXControl->MyMethod(5);  // fails - does nothing

Thanks for any assistance - I've been struggling to get this to work since
BCB3.

- Mary

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

 

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


VB ActiveX controls are not exactly ActiveX controls internally. If you do
an ActiveX control in VC++ it will work with BCB.

Quote
m...@interactive.net wrote in message <7av0cg$ss...@nnrp1.dejanews.com>...
>Can anyone confirm or deny whether BCB4 can use OCX's created with VB5 or
VB6?
>I just got my copy of BCB4, and tried creating a simple ActiveX Control in
>VB6.  The ActiveX has one property and one method.

>The control imports fine into the BCB4 IDE, but when I use the control in a
>project, the property works fine (I can "get" and "set" it), but the method
>fails (no exceptions, no error messages - it just doesn't work).

>MyActiveXControl->MyProp = 5;   // works great!
>MyActiveXControl->MyMethod(5);  // fails - does nothing

>Thanks for any assistance - I've been struggling to get this to work since
>BCB3.

>- Mary

>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


I thought ActiveX was a standard that was binary compatible and language
independent?

Quote
Alexis Rios wrote:

> VB ActiveX controls are not exactly ActiveX controls internally. If you do
> an ActiveX control in VC++ it will work with BCB.

> m...@interactive.net wrote in message <7av0cg$ss...@nnrp1.dejanews.com>...
> >Can anyone confirm or deny whether BCB4 can use OCX's created with VB5 or
> VB6?
> >I just got my copy of BCB4, and tried creating a simple ActiveX Control in
> >VB6.  The ActiveX has one property and one method.

> >The control imports fine into the BCB4 IDE, but when I use the control in a
> >project, the property works fine (I can "get" and "set" it), but the method
> >fails (no exceptions, no error messages - it just doesn't work).

> >MyActiveXControl->MyProp = 5;   // works great!
> >MyActiveXControl->MyMethod(5);  // fails - does nothing

> >Thanks for any assistance - I've been struggling to get this to work since
> >BCB3.

> >- Mary

> >-----------== Posted via Deja News, The Discussion Network ==----------
> >http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

--
Mike / mike_n...@hotmail.com

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


It's supposed to be.

Here's the problem:

activex controls usually present two interfaces, a vtable interface which is
determinable
via a type library, and an automation interface. using the vtable interface is
much faster.

theoretically, activex controls are supposed to lay out their methods
sequentially, so
that they are easily addressable. That is, in a typical ActiveX, QueryInterface
is at some address x,
and AddRef is at x+sizeof(pointer), and Release is at x+2*sizeof(pointer), etc.

VB does not always place its methods at the address expected. That is to say, in
a VB-created
ActiveX control derived from IUnknown with 2 new methods, it is not guaranteed
that
the first method is at x+3*sizeof(pointer). Our implementation assumes that it
is --- as all
of the COM specifications say it _should_ be --- and so blows up, calling an
address
that doesn't exist.

VC was actually broken by this for a while, as well. We are _very_ aware of the
problem,
and are working to fix it --- but all of our code that assumes sequential
implementation
of functions accessed via a vtable interface has to be rewritten.

As a workaround, if you go through automation, instead of vtable interface, it
will work.

Quote
"Mr. Mike" wrote:

> I thought ActiveX was a standard that was binary compatible and language
> independent?

> Alexis Rios wrote:

> > VB ActiveX controls are not exactly ActiveX controls internally. If you do
> > an ActiveX control in VC++ it will work with BCB.

> > m...@interactive.net wrote in message <7av0cg$ss...@nnrp1.dejanews.com>...
> > >Can anyone confirm or deny whether BCB4 can use OCX's created with VB5 or
> > VB6?
> > >I just got my copy of BCB4, and tried creating a simple ActiveX Control in
> > >VB6.  The ActiveX has one property and one method.

> > >The control imports fine into the BCB4 IDE, but when I use the control in a
> > >project, the property works fine (I can "get" and "set" it), but the method
> > >fails (no exceptions, no error messages - it just doesn't work).

> > >MyActiveXControl->MyProp = 5;   // works great!
> > >MyActiveXControl->MyMethod(5);  // fails - does nothing

> > >Thanks for any assistance - I've been struggling to get this to work since
> > >BCB3.

> > >- Mary

> > >-----------== Posted via Deja News, The Discussion Network ==----------
> > >http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

> --
> Mike / mike_n...@hotmail.com

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Quote
> As a workaround, if you go through automation, instead of vtable interface, it
> will work.

I just installed the ActiveX control by going to add components and then
clicking on ActiveX.  Is this using automation or the vtable method??

--
Mike / mike_n...@hotmail.com

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Vtable.

You need to import the type library, and then use that ATL wrapper class,
rather than the VCL wrapper created by installing the ActiveX on the
component. Use pointer indirection for automation.

Quote
"Mr. Mike" wrote:

> > As a workaround, if you go through automation, instead of vtable interface, it
> > will work.

> I just installed the ActiveX control by going to add components and then
> clicking on ActiveX.  Is this using automation or the vtable method??

> --
> Mike / mike_n...@hotmail.com

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


On Wed, 10 Mar 1999 11:19:55 -0800, aphrael <aphr...@burble.org>
wrote:

Quote
>It's supposed to be.

>Here's the problem:
>  [snip]

Additional thought (excuse the length, please):
I haven't ever touched ActiveX (have no tool yet), and my BCB4 is to
arrive here next week.  However, I've had to deal a little with older
versions of MS's BASIC (QB45, VBA 16-bit, VB5) and calls to/from it
from/to BC++.  The dominating issue there was/is the type of argument:
by value (C/C++ default) or by reference (BASIC default).  If I
remember right, the latter is NOT the C++-style reference argument as
in
        void myfunc(int &myarg) ;
but rather the C-compatible
        void myfunc(int *myarg) ;
The example given in the post that started this thread showed a
standard argument (a constant integer 5), suggesting a by-value
convention.  Could that play any role ?

Cheers,                    Jochen

************************************
Hans-Jochen Trost, Ph.D.
MicroFab Technologies, Inc.
1104 Summit Ave., Suite 110
Plano, TX 75074, USA
Phone:  (1)(972) 578-8076
Fax:    (1)(972) 423-2438
E-mail: hjtr...@microfab.com
Company home page:
   http://www.microfab.com
************************************

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Quote
Hans-Jochen Trost wrote:

> On Wed, 10 Mar 1999 11:19:55 -0800, aphrael <aphr...@burble.org>
> wrote:

> >It's supposed to be.

> >Here's the problem:
> >  [snip]

> Additional thought (excuse the length, please):
> I haven't ever touched ActiveX (have no tool yet), and my BCB4 is to
> arrive here next week.  However, I've had to deal a little with older
> versions of MS's BASIC (QB45, VBA 16-bit, VB5) and calls to/from it
> from/to BC++.  The dominating issue there was/is the type of argument:
> by value (C/C++ default) or by reference (BASIC default).  If I
> remember right, the latter is NOT the C++-style reference argument as
> in
>         void myfunc(int &myarg) ;
> but rather the C-compatible
>         void myfunc(int *myarg) ;
> The example given in the post that started this thread showed a
> standard argument (a constant integer 5), suggesting a by-value
> convention.  Could that play any role ?

Nope. :)

The COM marshaller, in this case, requires that it be a pointer
(if it's an out parameter); VB hides this from you.

Good thought, tho.

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


On Thu, 11 Mar 1999 11:00:16 -0800, aphrael <aphr...@burble.org>
wrote:

Quote
>Nope. :)

>The COM marshaller, in this case, requires that it be a pointer
>(if it's an out parameter); VB hides this from you.

>Good thought, tho.

Just to get my understanding right:  Mary tried to use
        MyActiveXControl->MyMethod(5);  // fails - does nothing
which in C/C++ is using a by-value argument, or in C++ possibly a
C++-reference style one.  If this is expected to be a pointer, all
hell may break loose because at byte 5, there could be anything, or
nothing.  So my concern would still be relevant?

Cheers,                jochen

************************************
Hans-Jochen Trost, Ph.D.
MicroFab Technologies, Inc.
1104 Summit Ave., Suite 110
Plano, TX 75074, USA
Phone:  (1)(972) 578-8076
Fax:    (1)(972) 423-2438
E-mail: hjtr...@microfab.com
Company home page:
   http://www.microfab.com
************************************

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Quote
> Just to get my understanding right:  Mary tried to use
>         MyActiveXControl->MyMethod(5);  // fails - does nothing
> which in C/C++ is using a by-value argument, or in C++ possibly a
> C++-reference style one.  If this is expected to be a pointer, all
> hell may break loose because at byte 5, there could be anything, or
> nothing.  So my concern would still be relevant?

It it were expecting a pointer and an integer was passed, would that
even compile?

--
Mike / mike_n...@hotmail.com

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Quote
Hans-Jochen Trost wrote:

> On Thu, 11 Mar 1999 11:00:16 -0800, aphrael <aphr...@burble.org>
> wrote:

> >Nope. :)

> >The COM marshaller, in this case, requires that it be a pointer
> >(if it's an out parameter); VB hides this from you.

> >Good thought, tho.

> Just to get my understanding right:  Mary tried to use
>         MyActiveXControl->MyMethod(5);  // fails - does nothing
> which in C/C++ is using a by-value argument, or in C++ possibly a
> C++-reference style one.  If this is expected to be a pointer, all
> hell may break loose because at byte 5, there could be anything, or
> nothing.  So my concern would still be relevant?

OK, there are two issues here.

(1) only _out_ parameters are expected to be pointer types. If this isn't
an out parameter, then there isn't a problem.

(2) The MyActiveXControl wrapper class may obscure the underlying method
for you.

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Any chance of a more detailed explanation for those of us just heading down this road!

e.g. what is the type library, how do you invoke and use the ATL wrapper class?

Quote
aphrael wrote:
> Vtable.

> You need to import the type library, and then use that ATL wrapper class,
> rather than the VCL wrapper created by installing the ActiveX on the
> component. Use pointer indirection for automation.

> "Mr. Mike" wrote:

> > > As a workaround, if you go through automation, instead of vtable interface, it
> > > will work.

> > I just installed the ActiveX control by going to add components and then
> > clicking on ActiveX.  Is this using automation or the vtable method??

> > --
> > Mike / mike_n...@hotmail.com

--
Ross Ashman
Lasers and Bio-Engineering Group
Centre for Ophthalmology and Visual Science
University of Western Australia

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Answered in private mail.
Ross: so that I don't have to write it up again, can you post my response to
this? :)
Quote
ross wrote:

> Any chance of a more detailed explanation for those of us just heading down this road!

> e.g. what is the type library, how do you invoke and use the ATL wrapper class?

> aphrael wrote:

> > Vtable.

> > You need to import the type library, and then use that ATL wrapper class,
> > rather than the VCL wrapper created by installing the ActiveX on the
> > component. Use pointer indirection for automation.

> > "Mr. Mike" wrote:

> > > > As a workaround, if you go through automation, instead of vtable interface, it
> > > > will work.

> > > I just installed the ActiveX control by going to add components and then
> > > clicking on ActiveX.  Is this using automation or the vtable method??

> > > --
> > > Mike / mike_n...@hotmail.com

> --
> Ross Ashman
> Lasers and Bio-Engineering Group
> Centre for Ophthalmology and Visual Science
> University of Western Australia

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Just wanted to thank everyone for the replies.  I hadn't heard anything for
several days, so I was starting to think not many people were attempting to
use VB5/6 ActiveX controls in Builder.  Ross, if you could post aphrael's
response, I know there's at least one person who would really appreciate it!

By the way, for those wondering about parameter pointer syntax, etc., even
calling a simple subroutine, with no return value and no parameters, was
failing using the vtable method.  For example,

   MyActiveXControl->SayHello();

would not work.

Thanks again for responding, everyone.  Now at least I know it's not just me!

- Mary

In article <36ED37E0.C6E7...@burble.org>,
  aphrael <aphr...@burble.org> wrote:

Quote
> Answered in private mail.
> Ross: so that I don't have to write it up again, can you post my response to
> this? :)

> ross wrote:

> > Any chance of a more detailed explanation for those of us just heading down
this road!

> > e.g. what is the type library, how do you invoke and use the ATL wrapper
class?

> > aphrael wrote:

> > > Vtable.

> > > You need to import the type library, and then use that ATL wrapper class,
> > > rather than the VCL wrapper created by installing the ActiveX on the
> > > component. Use pointer indirection for automation.

> > > "Mr. Mike" wrote:

> > > > > As a workaround, if you go through automation, instead of vtable
interface, it
> > > > > will work.

> > > > I just installed the ActiveX control by going to add components and then
> > > > clicking on ActiveX.  Is this using automation or the vtable method??

> > > > --
> > > > Mike / mike_n...@hotmail.com

> > --
> > Ross Ashman
> > Lasers and Bio-Engineering Group
> > Centre for Ophthalmology and Visual Science
> > University of Western Australia

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Re:BCB4 still cannot use VB5/VB6 ActiveX Controls?


Quote
ross writes:
> Any chance of a more detailed explanation for those of us just heading down t
   >his road!

> e.g. what is the type library, how do you invoke and use the ATL wrapper clas

   >s?

do an import type library (i think it's under project) on either
the .tl, .ocx, or .exe which constitutes your activex control.
this will generate some .h and .cpp files that constitute
the atl wrapper class.

there will be within those files something that looks like:

TCOMIInterfaceName. instantiate that, and then call
methods using pointer indirection (MyInstance->Func())
rather than static method calls (MyInstance.Func()).

Quote
> aphrael wrote:

> > Vtable.

> > You need to import the type library, and then use that ATL wrapper class,
> > rather than the VCL wrapper created by installing the ActiveX on the
> > component. Use pointer indirection for automation.

> > "Mr. Mike" wrote:

> > > > As a workaround, if you go through automation, instead of vtable interf
   >ace, it
> > > > will work.

> > > I just installed the ActiveX control by going to add components and then
> > > clicking on ActiveX.  Is this using automation or the vtable method??

> > > --
> > > Mike / mike_n...@hotmail.com

> --
> Ross Ashman
> Lasers and Bio-Engineering Group
> Centre for Ophthalmology and Visual Science
> University of Western Australia

aphrael wrote:
> Answered in private mail.
> Ross: so that I don't have to write it up again, can you post my response to
> this? :)

> ross wrote:

> > Any chance of a more detailed explanation for those of us just heading down this road!

> > e.g. what is the type library, how do you invoke and use the ATL wrapper class?

> > aphrael wrote:

> > > Vtable.

> > > You need to import the type library, and then use that ATL wrapper class,
> > > rather than the VCL wrapper created by installing the ActiveX on the
> > > component. Use pointer indirection for automation.

> > > "Mr. Mike" wrote:

> > > > > As a workaround, if you go through automation, instead of vtable interface, it
> > > > > will work.

> > > > I just installed the ActiveX control by going to add components and then
> > > > clicking on ActiveX.  Is this using automation or the vtable method??

> > > > --
> > > > Mike / mike_n...@hotmail.com

> > --
> > Ross Ashman
> > Lasers and Bio-Engineering Group
> > Centre for Ophthalmology and Visual Science
> > University of Western Australia

--
Lions Eye Institute
Lasers and Bio-Engineering Group
2 Verdun St.
Nedlands 6009
ph 08 9381 0731
fax o8 9381 0700

Other Threads