LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

The ActiveX controler gives me a hard time.

Hi.
I alredy put this question on the forum but a didn't get the answer so I will try to be more explicit.

I want to use 2 ActiveX controls: first when I create the calendar control and the second when I create an Excel control.

It doesn't mahters what control I create first, the second one fails to be created due to an error that apairs at the opening:
"ActiveX control error"

So I tried to use, before creating the second controler, this functions:
status = DiscardCtrl (My_handle, calendar);
CA_DiscardObjHandle (*objHandle);

because I was thinking that I must eliminate from memory the first ActiveX control, before I create the second one.

This solution doesn't work.

I put an example of what I try to
do. Press the Open Excel button before presing the Open Calendar button and you will see the error.

Thanks.
0 Kudos
Message 1 of 2
(3,055 Views)
Hi,

This is one of those situation where I know how to fix this but I don;t have the theory to support it. To be able to launch Excel and then the calendar control you need to change the ActiveX threading model.

For what I know, lauching Excel was initializing the ActiveX interface in COINIT_MULTITHREADED mode. Thus not allowing you to use ActiveX controls in that same thread. using the function call CA_InitActiveXThreadStyleForCurrentThread(0,COINIT_APARTMENTTHREADED) at the top of your code, you force CVI to use the COINIT_APARTMENTTHREADED threading mode that allows you to use ActiveX controls. You can find more details on this is the help for the function CA_InitActiveXThreadStyleForCurrentThread; make sure that you call this function before calling a
ny ActiveX functions.

Let me know if you have any further questions.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 2
(3,055 Views)