LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Control Error

Hello,

I have done an exemple program which is using a Date-Time Picker control (as an ActiveX control from mscomct2.ocx).
This example program is an executable and works fine.

Now I try to use the control in another program. This one is a dll, used by a TestStand sequence. But I get an error when the program is loading the panel (function LoadPanelEx). The message is "ActiveX Control Error", error code=-143.

Can anyone explain me the problem ?

Bruno
0 Kudos
Message 1 of 7
(4,948 Views)
Hi Bruno,

This error comes into play usually when the driver functions for the activeX control are not installed properly.
The solution would be to go back to the activeX control on the UIR and re-generate the driver functions.
Also, while making the distribution kit, it is advisable to include the activeX *.ocx file in the applications directory. That way you make sure that you are supplying the application with required *.ocx file to run the activeX control.
I hope it works for you.

regards,

Dwivedi
0 Kudos
Message 2 of 7
(4,928 Views)
Hi Dwivedi,

Thank you for your quick response.

I re-generated the driver for the ocx control and I copied the .ocx file to the dll directory.
But it doesn't work.

I tried to modify my project to generate an executable file, and I succeeded in loading the panel.
But it is not a solution for me because I need some informations from TestStand to perform the panel actions. I really need a dll (called from a TestStand sequence).

What are the differences between using an ActiveX control in a dll and using an ActiveX control in an executable ?
0 Kudos
Message 3 of 7
(4,901 Views)
Bruno,

I had a similar problem when using ActiveX controls in TestStand. (Independently in CVI the application using the ActiveX control worked fine, but from a DLL called in TestStand it failed with error -143.)

The problem may be something to do with the threading types.

An explanation given to me was as follows:

TestStand Engine: All execution threads are MTA unless you choose STA when
you call a sequence. So all code modules are executed in the MTA thread.

TestStand Operator Interface: All CVI Application threads are MTA unless
you are using Active X controls in the application. If so then
the thread is initialized as STA and not MTA.

This is why you are getting errors when you try to change the threading
model as your DLL was being loaded into the process and the process (CVI Operator Interface)
threads were set to STA model before that. Note: CVI sets the threading model to the required
type when the first COM library call is made in CVI's code.


It may be worthwhile having a look at some of NI's papers on multithreading for a better explanation!


Regards,

Brian
0 Kudos
Message 4 of 7
(4,884 Views)
The problem is the COM threading model being used by TestStand by default is not supported by the activex control. You will need to call the DLL in a new thread, and specify single threaded apartment (STA) as the threading model for the thread.
Bilal Durrani
NI
0 Kudos
Message 5 of 7
(4,878 Views)
To elaborate a little more, you will need to create a sequence call that will run in a new thread. On the "Settings" tab, you can select "Use Single-Threaded Apartment". If you would like your sequence to execute synchronously, you can obtain a reference to the new thread, and use a Wait step immediately after the Sequence Call step.

Allen P.
NI
0 Kudos
Message 6 of 7
(4,874 Views)
Hi all,

I call my dll in a sequence that is run in a new thread (using Single-Threaded Appartment) and it works fine !
Finally my problem was a TestStand problem and maybe I didn't post in the right forum.
I think I will follow your advice and have a look at some papers on multithreading.

Thank you for your answers.
Bruno
0 Kudos
Message 7 of 7
(4,835 Views)