Improvement to generated ActiveX methods?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Improvement to generated ActiveX methods?

Ted Bracht-2
Hi Blair,

I've got this VB ActiveX control, for which I generated the class + methods
through the Component Wizard.

At first it seemed to work but the output appeared to be rubbish. Looking
into the methods I started to suspect the SAFEARRAYs that were used as both
input and output parameters. Reading up on them in the recent newsgroup
articles I managed to fix it and got it all working nicely. The problem
seemed to me that the component wizard just uses the #asSAFEARRAY message to
convert a collection parameter into a SAFEARRAY, however, looking at the
library analysis, it seems that the type information of the elements inside
the SAFEARRAY is known as well at the time of generating the methods.
Therefore, instead of generating a method like:

 | answer |
 answer := (Array new: 2)
    basicAt: 1 put: mdblInputDataSet asSAFEARRAY;
    basicAt: 2 put: mdblTargetDataSet asSAFEARRAY;
    yourself.
...

have something like:

 | answer |
 answer := (Array new: 2)
    basicAt: 1 put: (SAFEARRAY withAll: mdblInputDataSet elementClass:
DOUBLE);
    basicAt: 2 put: (SAFEARRAY withAll: mdblTargetDataSet elementClass:
DOUBLE);
    yourself.
...

In my case not having set the element class of the SAFEARRAY caused the
problems. I don't know if this is a problem that only occurs when using VB
ActiveX controls, if not I can imagine that it would be an improvement to
the component wizard.

Thanks,

Ted
www.tedbracht.com