Home All Groups Group Topic Archive Search About

How to wrap a callback for VB6

Author
12 Jun 2009 7:31 PM
Hans Achim
Hello!

I have a Windows dll which can be easily used in VB6 using a tlb.
However, this Windows dll raises callbacks, and I haven't found an easy
way to receive them in VB6.
Being quite frustrated, I was thinking about an odder solution:

Would it be a good idea to make an ActiveX in C++ that I can call from
VB6 and which will raise the callback in VB6??

Thank you for suggestions.

Regards,
Achim

Author
12 Jun 2009 10:23 PM
Bob Riemersma
I'd assume the solution involves a callback routine declared in a static
(BAS) module, then passing a pointer to it via the AddressOf operator in
VB6.

Show quoteHide quote
"Hans Achim" <h.ac***@gmx.de> wrote in message
news:eYP$6S56JHA.5828@TK2MSFTNGP04.phx.gbl...
> Hello!
>
> I have a Windows dll which can be easily used in VB6 using a tlb.
> However, this Windows dll raises callbacks, and I haven't found an easy
> way to receive them in VB6.
> Being quite frustrated, I was thinking about an odder solution:
>
> Would it be a good idea to make an ActiveX in C++ that I can call from VB6
> and which will raise the callback in VB6??
>
> Thank you for suggestions.
>
> Regards,
> Achim
Author
12 Jun 2009 10:23 PM
MikeD
"Hans Achim" <h.ac***@gmx.de> wrote in message
news:eYP$6S56JHA.5828@TK2MSFTNGP04.phx.gbl...
> Hello!
>
> I have a Windows dll which can be easily used in VB6 using a tlb.
> However, this Windows dll raises callbacks, and I haven't found an easy
> way to receive them in VB6.
> Being quite frustrated, I was thinking about an odder solution:
>
> Would it be a good idea to make an ActiveX in C++ that I can call from VB6
> and which will raise the callback in VB6??
>

You can use the AddressOf operator to pass a function pointer to the DLL.
You can read more about the AddressOf operator here:

http://msdn.microsoft.com/en-us/library/aa242738(VS.60).aspx

However, I wouldn't call the ActiveX idea "odd".  In fact, it might be
better and easier.

--
Mike
Author
12 Jun 2009 10:30 PM
Jim Mack
Hans Achim wrote:
> Hello!
>
> I have a Windows dll which can be easily used in VB6 using a tlb.
> However, this Windows dll raises callbacks, and I haven't found an
> easy way to receive them in VB6.
> Being quite frustrated, I was thinking about an odder solution:
>
> Would it be a good idea to make an ActiveX in C++ that I can call
> from VB6 and which will raise the callback in VB6??

The standard way to recieve callbacks is using AddressOf for a Sub in
a standard module.

But there are gotchas, and some of them won't be solved by having an
intermediary. If your intermediary can raise events in VB rather than
just passing on a call, you'll eliminate almost every problem.

What types of parameters are sent to the called-back function? Does
the callback originate on a separate thread?

--
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"