Hello,
I am trying to create a step type for TestStand, that popups a CVI-panel (.uir) with some text and graphics.
If a certain parameter is passed to the cvi-dll (that shows the popup) an ActiveX Control should be placed on that panel.
Everything works fine, except the ActiveX Control. I get error -143(CVI-error), -2147467259 (WIN-error) each time when I try to create that panel with
NewActiveXCtrl on the panel.
By putting the ActiveX Control code in an executable, I do not get this error, so the code should work somehow.
As far as I know TestStand calls its modules multi-threaded (MTA), but an ActiveX Control needs to be in a single-threaded apartment (STA).
I have already found the ...\National Instruments\TestStand 3.1\Examples\MFCActiveXContainerDlg example, that shows how to
call a moudle in STA using a sequence call, but the step type is going to used very often in my sequence and I don't want to complicate my sequence with unnecessary sequence calls. Besides I want the panel to be executed in a separate thread in order to have the possibility to let the panel exist longer than the duration of a single TestStand step.
To summarize the above: I need a dll that can be called multi-threaded from TestStand and handles a ActiveX Control in single-threaded apartment.
I have already tried to start a new thread out of my dll with:
CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, (ThreadFunctionPtr)CreateWActiveXCtrl, &panel, NULL);
int CVICALLBACK CreateActiveXCtrl(int *panel)
{
..
}
but without any success and the same error messages from above.
When I try to set the thread with:
CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED)
I can't change the thread-style because it was already set when called by TestStand to MTA and moreover I just want to set the thread of the ActiveXCtrl to STA and not the other parts of the DLL.
Does someone has a solution?
Mathias
Message Edited by MaWie on 10-31-2005 03:50 AM
Message Edited by MaWie on 10-31-2005 03:52 AM